You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::SQS::Message

Inherits:
Resources::Resource show all
Defined in:
(unknown)

Instance Attribute Summary collapse

Attributes inherited from Resources::Resource

#client, #identifiers

Instance Method Summary collapse

Methods inherited from Resources::Resource

add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until

Methods included from Resources::OperationMethods

#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations

Constructor Details

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

Overloads:

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

    Parameters:

    • queue_url (String)
    • receipt_handle (String)

    Options Hash (options):

    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

  • #initialize(options = {}) ⇒ Object

    Options Hash (options):

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

      When `:client is not given, the options hash is used to construct a new Client object.

Instance Attribute Details

#attributesHash<String,String> (readonly)

SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp. SentTimestamp and ApproximateFirstReceiveTimestamp are each returned as an integer representing the epoch time in milliseconds.

Returns:

  • (Hash<String,String>)

    SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp.

#bodyString (readonly)

The message\'s contents (not URL-encoded).

Returns:

  • (String)

    The message\'s contents (not URL-encoded).

#md5_of_bodyString (readonly)

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

Returns:

  • (String)

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

#md5_of_message_attributesString (readonly)

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.

Returns:

  • (String)

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

#message_attributesHash<String,Types::MessageAttributeValue> (readonly)

Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items and Validation in the Amazon Simple Queue Service Developer Guide.

Returns:

#message_idString (readonly)

A unique identifier for the message. A MessageIdis considered unique across all AWS accounts for an extended period of time.

Returns:

  • (String)

    A unique identifier for the message.

#queue_urlString (readonly)

Returns:

  • (String)

#receipt_handleString (readonly)

Returns:

  • (String)

Instance Method Details

#change_visibility(options = {}) ⇒ Struct

Changes the visibility timeout of a specified message in a queue to a new value. The maximum allowed timeout value is 12 hours. Thus, you can't extend the timeout of a message in an existing queue to more than a total visibility timeout of 12 hours. For more information, see Visibility Timeout in the Amazon Simple Queue Service Developer Guide.

For example, you have a message with a visibility timeout of 5 minutes. After 3 minutes, you call ChangeMessageVisiblity with a timeout of 10 minutes. At that time, the timeout for the message is extended by 10 minutes beyond the time of the ChangeMessageVisibility action. This results in a total visibility timeout of 13 minutes. You can continue to call the ChangeMessageVisibility to extend the visibility timeout to a maximum of 12 hours. If you try to extend the visibility timeout beyond 12 hours, your request is rejected.

A message is considered to be in flight after it's received from a queue by a consumer, but not yet deleted from the queue.

For standard queues, there can be a maximum of 120,000 inflight messages per queue. If you reach this limit, Amazon SQS returns the OverLimit error message. To avoid reaching the limit, you should delete messages from the queue after they're processed. You can also increase the number of queues you use to process your messages.

For FIFO queues, there can be a maximum of 20,000 inflight messages per queue. If you reach this limit, Amazon SQS returns no error messages.

If you attempt to set the VisibilityTimeout to a value greater than the maximum time left, Amazon SQS returns an error. Amazon SQS doesn't automatically recalculate and increase the timeout to the maximum remaining time.

Unlike with a queue, when you change the visibility timeout for a specific message the timeout value is applied immediately but isn't saved in memory for that message. If you don't delete a message after it is received, the visibility timeout for the message reverts to the original timeout value (not to the value you set using the ChangeMessageVisibility action) the next time the message is received.

Examples:

Request syntax example with placeholder values


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

Options Hash (options):

  • :visibility_timeout (required, Integer)

    The new value for the message\'s visibility timeout (in seconds). Values values: 0 to 43200. Maximum: 12 hours.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#deleteStruct

Deletes the specified message from the specified queue. You specify the message by using the message's receipt handle and not the MessageId you receive when you send the message. Even if the message is locked by another reader due to the visibility timeout setting, it is still deleted from the queue. If you leave a message in the queue for longer than the queue's configured retention period, Amazon SQS automatically deletes the message.

The receipt handle is associated with a specific instance of receiving the message. If you receive a message more than once, the receipt handle you get each time you receive the message is different. If you don't provide the most recently received receipt handle for the message when you use the DeleteMessage action, the request succeeds, but the message might not be deleted.

For standard queues, it is possible to receive a message even after you delete it. This might happen on rare occasions if one of the servers storing a copy of the message is unavailable when you send the request to delete the message. The copy remains on the server and might be returned to you on a subsequent receive request. You should ensure that your application is idempotent, so that receiving a message more than once does not cause issues.

Examples:

Request syntax example with placeholder values


message.delete()

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#queueQueue

Returns: