Method: Aws::SQS::Client#send_message_batch

Defined in:
lib/aws-sdk-sqs/client.rb

#send_message_batch(params = {}) ⇒ Types::SendMessageBatchResult

Delivers up to ten messages to the specified queue. This is a batch version of ‘ SendMessage.` For a FIFO queue, multiple messages within a single batch are enqueued in the order they are sent.

The result of sending each message is reported individually in the response. Because the batch request can result in a combination of successful and unsuccessful actions, you should check for batch errors even when the call returns an HTTP status code of ‘200`.

The maximum allowed individual message size and the maximum total payload size (the sum of the individual lengths of all of the batched messages) are both 256 KB (262,144 bytes).

A message can include only XML, JSON, and unformatted text. The following Unicode characters are allowed:

`#x9` \| `#xA` \| `#xD` \| `#x20` to `#xD7FF` \| `#xE000` to `#xFFFD`

| ‘#x10000` to `#x10FFFF`

Any characters not included in this list will be rejected. For more

information, see the [W3C specification for characters].

If you don’t specify the ‘DelaySeconds` parameter for an entry, Amazon SQS uses the default value for the queue.

Some actions take lists of parameters. These lists are specified using the ‘param.n` notation. Values of `n` are integers starting from 1. For example, a parameter list with two elements looks like this:

‘&Attribute.1=first`

‘&Attribute.2=second`

[1]: www.w3.org/TR/REC-xml/#charsets

Examples:

Request syntax with placeholder values


resp = client.send_message_batch({
  queue_url: "String", # required
  entries: [ # required
    {
      id: "String", # required
      message_body: "String", # required
      delay_seconds: 1,
      message_attributes: {
        "String" => {
          string_value: "String",
          binary_value: "data",
          string_list_values: ["String"],
          binary_list_values: ["data"],
          data_type: "String", # required
        },
      },
      message_deduplication_id: "String",
      message_group_id: "String",
    },
  ],
})

Response structure


resp.successful #=> Array
resp.successful[0].id #=> String
resp.successful[0].message_id #=> String
resp.successful[0].md5_of_message_body #=> String
resp.successful[0].md5_of_message_attributes #=> String
resp.successful[0].sequence_number #=> String
resp.failed #=> Array
resp.failed[0].id #=> String
resp.failed[0].sender_fault #=> Boolean
resp.failed[0].code #=> String
resp.failed[0].message #=> String

Parameters:

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

    ({})

Options Hash (params):

  • :queue_url (required, String)

    The URL of the Amazon SQS queue to which batched messages are sent.

    Queue URLs and names are case-sensitive.

  • :entries (required, Array<Types::SendMessageBatchRequestEntry>)

    A list of ‘ SendMessageBatchRequestEntry ` items.

Returns:

See Also:



1781
1782
1783
1784
# File 'lib/aws-sdk-sqs/client.rb', line 1781

def send_message_batch(params = {}, options = {})
  req = build_request(:send_message_batch, params)
  req.send_request(options)
end