'SQS messages not returning all messages using AWS SDK Java
I'm trying to retrieve all messages from my SQS queue using AWS Java SDK, but it always return only one message. I've set maxNumberOfMessages(10) still it return only one message. Please find my code below - what I'm missing here. In my queue I've more than 10k records.
And how can I read more than 10 messages, looks like the max limit is we can read up-to 10 message only. If I want to process 10k records how can we do that?
It would be really appreciated if you could assist me with these two issues. Thanks!
public void getMessage(String queue) {
ReceiveMessageRequest receiveMessageRequest = ReceiveMessageRequest.builder()
.queueUrl(queue)
.waitTimeSeconds(10)
.maxNumberOfMessages(10)
.build();
List<Message> messages = sqsClient.receiveMessage(receiveMessageRequest).messages();
for (Message msg : messages) {
System.out.println("msgID: "+msg.messageId());
System.out.println("message: "+msg.body());
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
