peekBatch method
Peeks multiple incoming messages from the queue without removing them. If there are no messages available in the queue it returns an empty list.
correlationId
(optional) transaction id to trace execution through call chain.messageCount
a maximum number of messages to peek. Returns a list with peeked messages.
Implementation
@override
Future<List<MessageEnvelope?>> peekBatch(
String? correlationId, int messageCount) async {
checkOpen(correlationId);
// Subscribe to topic if needed
await subscribe(correlationId);
// Peek a batch of messages
var messages = _messages.getRange(0, messageCount).toList();
logger.trace(correlationId, 'Peeked %d messages on %s',
[messages.length, getName()]);
return messages;
}