Jiten Gupta
Jiten Gupta

Reputation: 161

Polling Interval for JMS MessageListener with SQS Provider

I am using amazon sqs queues to consume message asynchronously. I have started consuming the messages using amazon sqs JMS api's. So I have implemented MessageListener and doing my work once message arrive in onMessage method. Since amazon sqs is charged based on request made to the server I would like to restrict polling interval to 1 minute or may be more since I do not need message immediately.

I there anyway we can configure polling interval in JMS or I should use amazon sqs API to handle this on my own.

Thanks

Upvotes: 5

Views: 3640

Answers (2)

Oleg Dulin
Oleg Dulin

Reputation: 1447

Take a look at my blog post I wrote while back on this subject: http://thedulinreport.com/2015/05/09/guaranteeing-delivery-of-messages-with-aws-sqs/

The blog post explains how to implement asynchronous listeners using nothing but AWS SDK as well as provides links to examples on github.

Upvotes: 0

Shashi
Shashi

Reputation: 15263

In that case you could choose synchronous receive call i.e. consumer.receive(timeout) instead of message listener. You can make the receive call only when you want.

I am also wondering a bit as the onMessage method should be invoked by SQS messaging provider only when there is a message in the queue. There should be no polling involved here.

Update:

SQS provides JMS a implementation. So the AsyncMessageListener should definitely do the job your are looking for. This AsyncMessageListener sample should help you.

Upvotes: 1

Related Questions