QueueClient.receiveMessages Method
Definition
Overloads
| receiveMessages(Integer maxMessages) |
Retrieves up to the maximum number of messages from the queue and hides them from other operations for 30 seconds. Code Samples Receive up to 5 messages
For more information, see the Azure Docs. |
| receiveMessages(Integer maxMessages, Duration visibilityTimeout, Duration timeout, Context context) |
Retrieves up to the maximum number of messages from the queue and hides them from other operations for the timeout period. Code Samples Receive up to 5 messages and give them a 60 second timeout period
For more information, see the Azure Docs. |
receiveMessages(Integer maxMessages)
Retrieves up to the maximum number of messages from the queue and hides them from other operations for 30 seconds.
Code Samples
Receive up to 5 messages
for (QueueMessageItem message : client.receiveMessages(5)) {
System.out.printf("Received %s and it becomes visible at %s",
message.getMessageId(), message.getTimeNextVisible());
}
For more information, see the Azure Docs.
public PagedIterable<QueueMessageItem> receiveMessages(Integer maxMessages)
Parameters
- maxMessages
- java.lang.Integer
Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 messages.
Returns
Up to maxMessages QueueMessageItem from the queue.
Each ReceiveMessageItem contains getMessageId() and
getPopReceipt()
used to interact with the message and other metadata about the message.
receiveMessages(Integer maxMessages, Duration visibilityTimeout, Duration timeout, Context context)
Retrieves up to the maximum number of messages from the queue and hides them from other operations for the timeout period.
Code Samples
Receive up to 5 messages and give them a 60 second timeout period
for (QueueMessageItem message : client.receiveMessages(5, Duration.ofSeconds(60),
Duration.ofSeconds(1), new Context(key1, value1))) {
System.out.printf("Received %s and it becomes visible at %s",
message.getMessageId(), message.getTimeNextVisible());
}
For more information, see the Azure Docs.
public PagedIterable<QueueMessageItem> receiveMessages(Integer maxMessages, Duration visibilityTimeout, Duration timeout, Context context)
Parameters
- maxMessages
- java.lang.Integer
Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 messages.
- visibilityTimeout
- java.time.Duration
Optional. The timeout period for how long the message is invisible in the queue. If left empty the received messages will be invisible for 30 seconds. The timeout must be between 1 second and 7 days.
- timeout
- java.time.Duration
An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
- context
- Context
Additional context that is passed through the Http pipeline during the service call.
Returns
Up to maxMessages QueueMessageItem from the queue. Each DeqeuedMessage
contains getMessageId() and
getPopReceipt()
used to interact with the message and other metadata about the message.