Class: Aws::SQS::Message

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
lib/aws-sdk-sqs/message.rb

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue_url, receipt_handle, options = {}) ⇒ Message #initialize(options = {}) ⇒ Message

Returns a new instance of Message.

Overloads:

  • #initialize(queue_url, receipt_handle, options = {}) ⇒ Message

    Parameters:

    • queue_url (String)
    • receipt_handle (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ Message

    Options Hash (options):

    • :queue_url (required, String)
    • :receipt_handle (required, String)
    • :client (Client)


24
25
26
27
28
29
30
31
# File 'lib/aws-sdk-sqs/message.rb', line 24

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @queue_url = extract_queue_url(args, options)
  @receipt_handle = extract_receipt_handle(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
  @waiter_block_warned = false
end

Instance Method Details

#attributesHash<String,String>

A map of the attributes requested in ‘ ReceiveMessage ` to their respective values. Supported attributes:

  • ‘ApproximateReceiveCount`

  • ‘ApproximateFirstReceiveTimestamp`

  • ‘MessageDeduplicationId`

  • ‘MessageGroupId`

  • ‘SenderId`

  • ‘SentTimestamp`

  • ‘SequenceNumber`

‘ApproximateFirstReceiveTimestamp` and `SentTimestamp` are each returned as an integer representing the [epoch time] in milliseconds.

[1]: en.wikipedia.org/wiki/Unix_time

Returns:

  • (Hash<String,String>)


90
91
92
# File 'lib/aws-sdk-sqs/message.rb', line 90

def attributes
  data[:attributes]
end

#bodyString

The message’s contents (not URL-encoded).

Returns:

  • (String)


61
62
63
# File 'lib/aws-sdk-sqs/message.rb', line 61

def body
  data[:body]
end

#change_visibility(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


message.change_visibility({
  visibility_timeout: 1, # required
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :visibility_timeout (required, Integer)

    The new value for the message’s visibility timeout (in seconds). Values range: ‘0` to `43200`. Maximum: 12 hours.

Returns:

  • (EmptyStructure)


161
162
163
164
165
166
167
168
169
170
# File 'lib/aws-sdk-sqs/message.rb', line 161

def change_visibility(options = {})
  options = options.merge(
    queue_url: @queue_url,
    receipt_handle: @receipt_handle
  )
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.change_message_visibility(options)
  end
  resp.data
end

#clientClient

Returns:



122
123
124
# File 'lib/aws-sdk-sqs/message.rb', line 122

def client
  @client
end

#dataTypes::Message

Returns the data for this Aws::SQS::Message.

Returns:

Raises:

  • (NotImplementedError)

    Raises when #data_loaded? is ‘false`.



137
138
139
140
# File 'lib/aws-sdk-sqs/message.rb', line 137

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



145
146
147
# File 'lib/aws-sdk-sqs/message.rb', line 145

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


message.delete()

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:

  • (EmptyStructure)


177
178
179
180
181
182
183
184
185
186
# File 'lib/aws-sdk-sqs/message.rb', line 177

def delete(options = {})
  options = options.merge(
    queue_url: @queue_url,
    receipt_handle: @receipt_handle
  )
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.delete_message(options)
  end
  resp.data
end

#identifiersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.


200
201
202
203
204
205
# File 'lib/aws-sdk-sqs/message.rb', line 200

def identifiers
  {
    queue_url: @queue_url,
    receipt_handle: @receipt_handle
  }
end

#loadObject Also known as: reload

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (NotImplementedError)


128
129
130
131
# File 'lib/aws-sdk-sqs/message.rb', line 128

def load
  msg = "#load is not implemented, data only available via enumeration"
  raise NotImplementedError, msg
end

#md5_of_bodyString

An MD5 digest of the non-URL-encoded message body string.

Returns:

  • (String)


55
56
57
# File 'lib/aws-sdk-sqs/message.rb', line 55

def md5_of_body
  data[:md5_of_body]
end

#md5_of_message_attributesString

An MD5 digest of the non-URL-encoded message attribute string. You can use this attribute to verify that Amazon SQS received the message correctly. Amazon SQS URL-decodes the message before creating the MD5 digest. For information about MD5, see [RFC1321].

[1]: www.ietf.org/rfc/rfc1321.txt

Returns:

  • (String)


103
104
105
# File 'lib/aws-sdk-sqs/message.rb', line 103

def md5_of_message_attributes
  data[:md5_of_message_attributes]
end

#message_attributesHash<String,Types::MessageAttributeValue>

Each message attribute consists of a ‘Name`, `Type`, and `Value`. For more information, see [Amazon SQS message attributes] in the *Amazon SQS Developer Guide*.

[1]: docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-metadata.html#sqs-message-attributes

Returns:



115
116
117
# File 'lib/aws-sdk-sqs/message.rb', line 115

def message_attributes
  data[:message_attributes]
end

#message_idString

A unique identifier for the message. A ‘MessageId`is considered unique across all Amazon Web Services accounts for an extended period of time.

Returns:

  • (String)


49
50
51
# File 'lib/aws-sdk-sqs/message.rb', line 49

def message_id
  data[:message_id]
end

#queueQueue

Returns:



191
192
193
194
195
196
# File 'lib/aws-sdk-sqs/message.rb', line 191

def queue
  Queue.new(
    url: @queue_url,
    client: @client
  )
end

#queue_urlString

Returns:

  • (String)


36
37
38
# File 'lib/aws-sdk-sqs/message.rb', line 36

def queue_url
  @queue_url
end

#receipt_handleString

Returns:

  • (String)


41
42
43
# File 'lib/aws-sdk-sqs/message.rb', line 41

def receipt_handle
  @receipt_handle
end