Class: Fog::Rackspace::Queues::Message

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/queues/message.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Attribute Details

#ageInteger (readonly)

Returns The number of seconds relative to the server’s clock.

Returns:

  • (Integer)

    The number of seconds relative to the server’s clock.



10
# File 'lib/fog/rackspace/models/queues/message.rb', line 10

attribute :age

#bodyString, ...

Returns specifies an arbitrary document that constitutes the body of the message being sent. The size of this body is limited to 256 KB, excluding whitespace. The document must be valid JSON.

Returns:

  • (String, Hash, Array)

    specifies an arbitrary document that constitutes the body of the message being sent. The size of this body is limited to 256 KB, excluding whitespace. The document must be valid JSON.



20
# File 'lib/fog/rackspace/models/queues/message.rb', line 20

attribute :body

#claim_idString (readonly)

Returns the id of the claim.

Returns:

  • (String)

    the id of the claim



28
# File 'lib/fog/rackspace/models/queues/message.rb', line 28

attribute :claim_id

#hrefString (readonly)

Returns location of the message.

Returns:

  • (String)

    location of the message



24
# File 'lib/fog/rackspace/models/queues/message.rb', line 24

attribute :href

#identityString (readonly) Also known as: id

Returns The messages identity.

Returns:

  • (String)

    The messages identity



32
33
34
35
36
37
# File 'lib/fog/rackspace/models/queues/message.rb', line 32

def identity
  return nil unless href

  match = href.match(/(\/(\w+))*\??/)
  match ? match[-1] : nil
end

#ttlInteger

Note:

The value of ttl must be between 60 and 1209600 seconds (14 days). Note that the server might not actually delete the message until its

age has reached up to (ttl + 60) seconds, to allow for flexibility in storage implementations.

Returns:

  • (Integer)

    specifies how long the server waits before marking the message as expired and removing it from the queue.



16
# File 'lib/fog/rackspace/models/queues/message.rb', line 16

attribute :ttl

Instance Method Details

#destroyBoolean

Destroys Message



68
69
70
71
72
73
74
75
# File 'lib/fog/rackspace/models/queues/message.rb', line 68

def destroy
  requires :identity, :queue
  options = {}
  options[:claim_id] = claim_id unless claim_id.nil?

  service.delete_message(queue.name, identity, options)
  true
end

#saveBoolean

Note:

messages cannot be updated

Creates messages Requires queue, client_id, body, and ttl attributes to be populated



51
52
53
54
55
56
57
# File 'lib/fog/rackspace/models/queues/message.rb', line 51

def save
  requires :queue, :client_id, :body, :ttl
  raise "Message has already been created and may not be updated." unless identity.nil?
  data = service.create_message(client_id, queue.name, body, ttl).body
  self.href = data['resources'][0]
  true
end