Android-从AWS SQS获取消息 [英] Android - Getting messages from AWS SQS

查看:61
本文介绍了Android-从AWS SQS获取消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有从AWS SQS返回消息的功能:

I have function which returns messages from AWS SQS:

  public List<Message> getMessagesFromQueue(String queueUrl){
       ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);
       List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
       return messages;
    }

问题在于它每次都返回不同数量的消息,而不是我队列中的所有4条消息.

The problem is that it returns different number of messages each time, never all 4 which I have in the queue.

推荐答案

很遗憾听到您在使用API​​来使用API​​读取SQS队列时遇到困难.您可以在以下位置找到Java客户端提供的receiveMessage文档:

I am sorry to hear that you are having difficulty using the API to achieve reading the SQS queue using the API. You can find the documentation for receiveMessage from the Java client here:

receiveMessage的文档指出,可能会返回1至10条消息.可以通过调用ReceiveMessageRequest对象上的setMaxNumberOfMessages方法来限制返回的数量.但是,这仅限制了可以返回的最大邮件数量.要尝试读取队列中的所有消息,请尝试调用该方法,直到响应中没有消息返回为止.

The documentation for receiveMessage indicates that anywhere from 1 to 10 messages may be returned. The number returned may be limited by calling the setMaxNumberOfMessages method on the ReceiveMessageRequest object; however, this only limits the maximum amount of messages that may be returned. To attempt to read all the messages in the queue, try calling the method until no messages come back in the response.

这篇关于Android-从AWS SQS获取消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆