Class: WAZ::Queues::Message
- Inherits:
-
Object
- Object
- WAZ::Queues::Message
- Defined in:
- lib/waz/queues/message.rb
Overview
# remove the message from the queue
.destroy!
Instance Attribute Summary collapse
-
#dequeue_count ⇒ Object
Returns the value of attribute dequeue_count.
-
#expiration_time ⇒ Object
Returns the value of attribute expiration_time.
-
#insertion_time ⇒ Object
Returns the value of attribute insertion_time.
-
#message_id ⇒ Object
Returns the value of attribute message_id.
-
#message_text ⇒ Object
Returns the value of attribute message_text.
-
#pop_receipt ⇒ Object
Returns the value of attribute pop_receipt.
-
#time_next_visible ⇒ Object
Returns the value of attribute time_next_visible.
Class Method Summary collapse
-
.service_instance ⇒ Object
This method is internally used by this class.
Instance Method Summary collapse
-
#destroy! ⇒ Object
Marks the message for deletion (to later be removed from the queue by the garbage collector).
-
#initialize(params = {}) ⇒ Message
constructor
Creates an instance of Message class, this method is intended to be used internally from the Queue.
-
#queue_name ⇒ Object
Returns the Queue name where the Message belongs to.
Constructor Details
#initialize(params = {}) ⇒ Message
Creates an instance of Message class, this method is intended to be used internally from the Queue.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/waz/queues/message.rb', line 40 def initialize(params = {}) self. = params[:message_id] self. = params[:message_text] self.pop_receipt = params[:pop_receipt] self.expiration_time = params[:expiration_time] self.insertion_time = params[:insertion_time] self.time_next_visible = params[:time_next_visible] self.dequeue_count = params[:dequeue_count] @queue_name = params[:queue_name] end |
Instance Attribute Details
#dequeue_count ⇒ Object
Returns the value of attribute dequeue_count.
36 37 38 |
# File 'lib/waz/queues/message.rb', line 36 def dequeue_count @dequeue_count end |
#expiration_time ⇒ Object
Returns the value of attribute expiration_time.
36 37 38 |
# File 'lib/waz/queues/message.rb', line 36 def expiration_time @expiration_time end |
#insertion_time ⇒ Object
Returns the value of attribute insertion_time.
36 37 38 |
# File 'lib/waz/queues/message.rb', line 36 def insertion_time @insertion_time end |
#message_id ⇒ Object
Returns the value of attribute message_id.
36 37 38 |
# File 'lib/waz/queues/message.rb', line 36 def @message_id end |
#message_text ⇒ Object
Returns the value of attribute message_text.
36 37 38 |
# File 'lib/waz/queues/message.rb', line 36 def @message_text end |
#pop_receipt ⇒ Object
Returns the value of attribute pop_receipt.
36 37 38 |
# File 'lib/waz/queues/message.rb', line 36 def pop_receipt @pop_receipt end |
#time_next_visible ⇒ Object
Returns the value of attribute time_next_visible.
36 37 38 |
# File 'lib/waz/queues/message.rb', line 36 def time_next_visible @time_next_visible end |
Class Method Details
.service_instance ⇒ Object
This method is internally used by this class. It’s the way we keep a single instance of the service that wraps the calls the Windows Azure Queues API. It’s initialized with the values from the default_connection on WAZ::Storage::Base initialized thru establish_connection!
30 31 32 33 |
# File 'lib/waz/queues/message.rb', line 30 def service_instance = WAZ::Storage::Base.default_connection.merge(:type_of_service => "queue") (@service_instances ||= {})[[:account_name]] ||= Service.new() end |
Instance Method Details
#destroy! ⇒ Object
Marks the message for deletion (to later be removed from the queue by the garbage collector). If the message where the message is being actually called was peeked from the queue instead of locked it will raise the WAZ::Queues:InvalidOperation exception since it’s not a permited operation.
59 60 61 62 |
# File 'lib/waz/queues/message.rb', line 59 def destroy! raise WAZ::Queues::InvalidOperation if pop_receipt.nil? self.class.service_instance.(queue_name, , pop_receipt) end |
#queue_name ⇒ Object
Returns the Queue name where the Message belongs to
52 53 54 |
# File 'lib/waz/queues/message.rb', line 52 def queue_name return @queue_name end |