Retrieve multiple messages from SQS

后端 未结 8 1971
逝去的感伤
逝去的感伤 2020-12-10 00:55

I have multiple messages in SQS. The following code always returns only one, even if there are dozens visible (not in flight). setMaxNumberOfMessages I th

8条回答
  •  情深已故
    2020-12-10 01:06

    I was just trying the same and with the help of these two attributes setMaxNumberOfMessages and setWaitTimeSeconds i was able to get 10 messages.

    ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myQueueUrl);
                          receiveMessageRequest.setMaxNumberOfMessages(10);
                          receiveMessageRequest.setWaitTimeSeconds(20);
    

    Snapshot of o/p:

    Receiving messages from TestQueue.
    Number of messages:10
    Message
    MessageId:     31a7c669-1f0c-4bf1-b18b-c7fa31f4e82d 
    ...
    

提交回复
热议问题