Polling Interval for JMS MessageListener with SQS Provider

夙愿已清 提交于 2019-12-11 10:37:31

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/29667321/polling-interval-for-jms-messagelistener-with-sqs-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!