Search code examples
amazon-web-servicesaws-lambdaamazon-sns

Sending multiple messages to SNS on a single call


I have a scenario where every time lambda runs, it will send 1000 messages to a SNS topic. I can loop through the list of messages and call the publish method 1000 times, one message at a time but I was wondering if there is a way to send multiple messages in one call. In that case I can batch the messages and call publish let say 10 with 100 messages on each execution.

I would really appreciate if someone can help on this.


Solution

  • With SNS publish you could publish message one by one, AWS does not provide a way to publish message in bulk or batch to SNS.

    Below is the possible solution you could try:

    You could use send-message-batch API and send bulk messages to SQS. That SQS will be subscribed by a SNS. Below is an image to create subscription to SQS:

    enter image description here