简体   繁体   English

如何使用 Amazon SQS Springn 云注释@SqsListener 轮询特定数量的消息

[英]How to Poll for a specific number of messages using Amazon SQS Springn cloud annotation @SqsListener

Need: to poll/listen 10 messages at a time(Specific count not based on polling time) Existing code base using spring cloud aws messaging polls based on time by default.需要:一次轮询/收听 10 条消息(具体计数不基于轮询时间)现有代码库默认使用 spring 云 aws 消息轮询基于时间。 now required to poll based on the counts of messages.现在需要根据消息数进行轮询。

Looking for a annotation based configuration similar approach to the below code寻找与以下代码类似的基于注释的配置方法

@SqsListener(value = "xxx-sqs",deletionPolicy = ON_SUCCESS)
public void auditProcessor(String json) throws IOException {
    log.info("*********** Inside Listner***********");
    log.info("JSON Data "+json);
}

Any help on this would be appreciated.对此的任何帮助将不胜感激。

The amount of messages requested from SQS can be configured in SimpleMessageListenerContainerFactory .从 SQS 请求的消息数量可以在 SimpleMessageListenerContainerFactory 中配置

That being said SQS works in a way that even if you ask for 10 messages you have no guarantee you will get 10 even if there are more messages in the queue.话虽如此,SQS 的工作方式是,即使您请求 10 条消息,也不能保证您会得到 10 条消息,即使队列中有更多消息。 You can only be sure that you will not get more than 10.你只能确定你不会得到超过 10 个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM