I am developing an application in which I need to send multiple events to SNS. Is there any way to send all the events in batch or do I need to send/ publish using a for-loop (I'm using Java) one by one to the SNS.
The publish()
API call only sends one message.
You will need to loop through your data and call publish()
for each message.
SNS now supports publishing a batch of messages!
The publish()
API call only sends one message.
You will need to loop through your data and call publish()
for each message.
You can publish a batch of 10 messages in a single request now. It reduces the cost of API requests by 90%.
Link has the Java code references of bulk publishing.
If you need to publish multiple events, then I suggest to use EventBridge instead of SNS. It might cost a little more but We can pass around 10 events/ API call using EventBridge PutEvents
API.
You can specify upto 5 targets as Lambda, SQS, etc. It can connect to all the services the SNS can pass on to and more.
© 2022 - 2024 — McMap. All rights reserved.