Class: WAZ::Queues::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/waz/queues/message.rb

Overview

# remove the message from the queue

message.destroy!

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.message_id = params[:message_id]
  self.message_text = 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_countObject

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_timeObject

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_timeObject

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_idObject

Returns the value of attribute message_id.



36
37
38
# File 'lib/waz/queues/message.rb', line 36

def message_id
  @message_id
end

#message_textObject

Returns the value of attribute message_text.



36
37
38
# File 'lib/waz/queues/message.rb', line 36

def message_text
  @message_text
end

#pop_receiptObject

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_visibleObject

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_instanceObject

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
  options = WAZ::Storage::Base.default_connection.merge(:type_of_service => "queue")
  (@service_instances ||= {})[options[:account_name]] ||= Service.new(options)
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.delete_message(queue_name, message_id, pop_receipt)
end

#queue_nameObject

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