publish_batch¶
Operation¶
publish_batch
async
¶
publish_batch(input: PublishBatchInput, plugins: list[Plugin] | None = None) -> PublishBatchOutput
Publishes up to 10 messages to the specified topic in a single batch.
This is a batch version of the Publish API. If you try to send more
than 10 messages in a single batch request, you will receive a
TooManyEntriesInBatchRequest exception.
For FIFO topics, multiple messages within a single batch are published in the order they are sent, and messages are deduplicated within the batch and across batches for five minutes.
The result of publishing 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.
By default, 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 KiB (262,144 bytes). To publish larger
batches, set the topic's MaximumMessageSize attribute, which supports
values up to 1 MiB (1,048,576 bytes). The combined size of all messages
in the batch, including each message's body and attributes, must not
exceed the topic's MaximumMessageSize.
For more information, see Large message payloads in the Amazon SNS Developer Guide.
Warning
The PublishBatch API can send up to 10 messages at a time. If you
attempt to send more than 10 messages in one request, you will encounter
a TooManyEntriesInBatchRequest exception. In such cases, split your
messages into multiple requests, each containing no more than 10
messages.
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:
&AttributeName.1=first
&AttributeName.2=second
If you send a batch message to a topic, Amazon SNS publishes the batch message to each endpoint that is subscribed to the topic. The format of the batch message depends on the notification protocol for each subscribed endpoint.
When a messageId is returned, the batch message is saved, and Amazon
SNS immediately delivers the message to subscribers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
PublishBatchInput
|
An instance of |
required |
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
Returns:
| Type | Description |
|---|---|
PublishBatchOutput
|
An instance of |
Input¶
PublishBatchInput
dataclass
¶
Dataclass for PublishBatchInput structure.
Attributes¶
publish_batch_request_entries
class-attribute
instance-attribute
¶
publish_batch_request_entries: list[PublishBatchRequestEntry] | None = None
A list of PublishBatch request entries to be sent to the SNS topic.
Output¶
PublishBatchOutput
dataclass
¶
Dataclass for PublishBatchOutput structure.
Attributes¶
failed
class-attribute
instance-attribute
¶
failed: list[BatchResultErrorEntry] | None = None
A list of failed PublishBatch responses.
response_metadata
class-attribute
instance-attribute
¶
response_metadata: ResponseMetadata = field(default=EMPTY_RESPONSE_METADATA, repr=False, compare=False)
Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.
successful
class-attribute
instance-attribute
¶
successful: list[PublishBatchResultEntry] | None = None
A list of successful PublishBatch responses.