KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have multiple messages in SQS. The following code always returns only one, even if there are dozens visible (not in flight). setMaxNumberOfMessages I thought would allow multiple to be consumed at once .. have i misunderstood this? CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName); String queueUrl = sqs.createQueue(createQueueRequest).getQueueUrl(); ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl); receiveMessageRequest.setMaxNumberOfMessages(10); List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages(); for (Message message : messages) { // i'm a message from SQS } I've also tried using withMaxNumberOfMessages without any such luck: receiveMessageRequest.withMaxNumberOfMessages(10); How do I know there are messages in the queue? More than 1? Set<String> attrs = new HashSet<String>(); attrs.add("ApproximateNumberOfMessages"); CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName); GetQueueAttributesRequest a = new GetQueueAttributesRequest().withQueueUrl(sqs.createQueue(createQueueRequest).getQueueUrl()).withAttributeNames(attrs); Map<String,String> result = sqs.getQueueAttributes(a).getAttributes(); int num = Integer.parseInt(result.get("ApproximateNumberOfMessages")); The above always is run prior and gives me an int that is >1 Thanks for your input
Tags (comma-separated)
Save Edits
Cancel