QueueClient.peekMessages(Integer maxMessages, Duration timeout, Context context) Method
Definition
Peek messages from the front of the queue up to the maximum number of messages. Peeked messages don't contain the necessary information needed to interact with the message nor will it hide messages from other operations on the queue.
Code Samples
Peek up to the first five messages
client.peekMessages(5, Duration.ofSeconds(1), new Context(key1, value1)).forEach(
peekMessage -> System.out.printf("Peeked message %s has been received %d times",
peekMessage.getMessageId(), peekMessage.getDequeueCount())
);
For more information, see the Azure Docs.
public PagedIterable<PeekedMessageItem> peekMessages(Integer maxMessages, Duration timeout, Context context)
Parameters
- maxMessages
- java.lang.Integer
Optional. Maximum number of messages to peek, if there are less messages exist in the queue than requested all the messages will be peeked. If left empty only 1 message will be peeked, the allowed range is 1 to 32 messages.
- 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 PeekedMessageItem from the queue. Each PeekedMessage
contains metadata about the message.