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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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.



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

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.



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

attribute :body

#claim_idString (readonly)

Returns the id of the claim.

Returns:

  • (String)

    the id of the claim



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

attribute :claim_id

#hrefString (readonly)

Returns location of the message.

Returns:

  • (String)

    location of the message



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

attribute :href

#identityString (readonly) Also known as: id

Returns The messages identity.

Returns:

  • (String)

    The messages identity



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

def identity
  return nil unless href

  match = href.match(/\A.*\/queues\/[a-zA-Z0-9_-]{0,64}\/messages\/(.+?)(?:\?|\z)/i)
  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.



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

attribute :ttl

Instance Method Details

#destroyBoolean

Destroys Message



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

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

Returns:

  • (Boolean)

    returns true if message has been succesfully saved

Raises:

See Also:



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

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