publish_batch
¶
publish_batch(
topic_arn: topicARN,
publish_batch_request_entries: PublishBatchRequestEntryList,
*,
config_overrides: Optional[SNSClientConfig] = None,
) -> PublishBatchResponse
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.
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:
-
topic_arn(topicARN) –The Amazon resource name (ARN) of the topic you want to batch publish to.
-
publish_batch_request_entries(PublishBatchRequestEntryList) –A list of
PublishBatchrequest entries to be sent to the SNS topic.
Raises:
-
AuthorizationErrorException–Indicates that the user has been denied access to the requested resource.
-
BatchEntryIdsNotDistinctException–Two or more batch entries in the request have the same
Id. -
BatchRequestTooLongException–The length of all the batch messages put together is more than the limit.
-
EmptyBatchRequestException–The batch request doesn't contain any entries.
-
EndpointDisabledException–Exception error indicating endpoint disabled.
-
InternalErrorException–Indicates an internal service error.
-
InvalidBatchEntryIdException–The
Idof a batch entry in a batch request doesn't abide by the specification. -
InvalidParameterException–Indicates that a request parameter does not comply with the associated constraints.
-
InvalidParameterValueException–Indicates that a request parameter does not comply with the associated constraints.
-
InvalidSecurityException–The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using Signature Version 4.
-
KMSAccessDeniedException–The ciphertext references a key that doesn't exist or that you don't have access to.
-
KMSDisabledException–The request was rejected because the specified Amazon Web Services KMS key isn't enabled.
-
KMSInvalidStateException–The request was rejected because the state of the specified resource isn't valid for this request. For more information, see Key states of Amazon Web Services KMS keys in the Key Management Service Developer Guide.
-
KMSNotFoundException–The request was rejected because the specified entity or resource can't be found.
-
KMSOptInRequired–The Amazon Web Services access key ID needs a subscription for the service.
-
KMSThrottlingException–The request was denied due to request throttling. For more information about throttling, see Limits in the Key Management Service Developer Guide.
-
NotFoundException–Indicates that the requested resource does not exist.
-
PlatformApplicationDisabledException–Exception error indicating platform application disabled.
-
TooManyEntriesInBatchRequestException–The batch request contains more entries than permissible (more than 10).
-
ValidationException–Indicates that a parameter in the request is invalid.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_sns/_services/sns.py
2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 | |