SQS Event monitoring from JavaScript

203 Views Asked by At

I have a web application that shows the content of a SQS Queue and I want to refresh the page (peek at the queue again) whenever some external process adds or dequeues a message.

What is the recommended best practice to observe SQS events from JavaScript?

1

There are 1 best solutions below

0
holly_cheng On

This is only partially possible. See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html. You can have a lambda function that will be triggered when a message arrives in the queue. That lambda could then post a notification via SNS to your page (for example, using SignalR if you use .NET).

However, there is nothing for when a message is deleted. You might just have to continuously check the number of messages in the queue + the number in flight, and when the total goes down, do your action. Naturally, you could the opposite to see when items are added (total message count increases).