peek method
Peeks a single incoming message from the queue without removing it. If there are no messages available in the queue it returns null.
correlationId
(optional) transaction id to trace execution through call chain. Returns a peeked message ornull
.
Implementation
@override
Future<MessageEnvelope?> peek(String? correlationId) async {
checkOpen(correlationId);
// Subscribe to topic if needed
await subscribe(correlationId);
// Peek a message from the top
MessageEnvelope? message;
if (_messages.isNotEmpty) {
message = _messages[0];
}
if (message != null) {
logger.trace(message.correlation_id, 'Peeked message %s on %s',
[message, getName()]);
}
return message;
}