Class: AliyunIot::Message
- Inherits:
-
Object
- Object
- AliyunIot::Message
- Defined in:
- lib/aliyun_iot/message.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#body_md5 ⇒ Object
readonly
Returns the value of attribute body_md5.
-
#dequeue_count ⇒ Object
readonly
Returns the value of attribute dequeue_count.
-
#enqueue_at ⇒ Object
readonly
Returns the value of attribute enqueue_at.
-
#first_enqueue_at ⇒ Object
readonly
Returns the value of attribute first_enqueue_at.
-
#h ⇒ Object
readonly
Returns the value of attribute h.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#next_visible_at ⇒ Object
readonly
Returns the value of attribute next_visible_at.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#receipt_handle ⇒ Object
readonly
Returns the value of attribute receipt_handle.
Instance Method Summary collapse
-
#change_visibility(seconds) ⇒ Object
修改消息可见时间.
-
#delete ⇒ Object
删除消息.
- #get_data ⇒ Object
-
#initialize(queue, h) ⇒ Message
constructor
A new instance of Message.
- #to_s ⇒ Object
Constructor Details
#initialize(queue, h) ⇒ Message
Returns a new instance of Message.
6 7 8 9 10 |
# File 'lib/aliyun_iot/message.rb', line 6 def initialize(queue, h) @h = h @queue = queue end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def body @body end |
#body_md5 ⇒ Object (readonly)
Returns the value of attribute body_md5.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def body_md5 @body_md5 end |
#dequeue_count ⇒ Object (readonly)
Returns the value of attribute dequeue_count.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def dequeue_count @dequeue_count end |
#enqueue_at ⇒ Object (readonly)
Returns the value of attribute enqueue_at.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def enqueue_at @enqueue_at end |
#first_enqueue_at ⇒ Object (readonly)
Returns the value of attribute first_enqueue_at.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def first_enqueue_at @first_enqueue_at end |
#h ⇒ Object (readonly)
Returns the value of attribute h.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def h @h end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def id @id end |
#next_visible_at ⇒ Object (readonly)
Returns the value of attribute next_visible_at.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def next_visible_at @next_visible_at end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def priority @priority end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def queue @queue end |
#receipt_handle ⇒ Object (readonly)
Returns the value of attribute receipt_handle.
4 5 6 |
# File 'lib/aliyun_iot/message.rb', line 4 def receipt_handle @receipt_handle end |
Instance Method Details
#change_visibility(seconds) ⇒ Object
修改消息可见时间
20 21 22 23 24 |
# File 'lib/aliyun_iot/message.rb', line 20 def change_visibility(seconds) check_receipt_handle data = set_data({ReceiptHandle: receipt_handle, VisibilityTimeout: seconds}) Request::Xml.put(queue., data) end |
#delete ⇒ Object
删除消息
13 14 15 16 17 |
# File 'lib/aliyun_iot/message.rb', line 13 def delete check_receipt_handle data = set_data({ReceiptHandle: receipt_handle}) Request::Xml.delete(queue., data) end |
#get_data ⇒ Object
26 27 28 |
# File 'lib/aliyun_iot/message.rb', line 26 def get_data data = JSON.parse(Base64.decode64 body) end |
#to_s ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/aliyun_iot/message.rb', line 30 def to_s s = { "队列" => queue.name, "ID" => id, "MD5" => body_md5, "Receipt handle" => receipt_handle, "Enqueue at" => enqueue_at, "First enqueue at" => first_enqueue_at, "Next visible at" => next_visible_at, "Dequeue count" => dequeue_count, "Priority" => priority }.collect { |k, v| "#{k}: #{v}" } sep = "\n=============================================>" s.unshift sep s << sep s << body puts s.join("\n") end |