peek method

  1. @override
Future<MessageEnvelope?> peek(
  1. String? correlationId
)
override

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. Return Future that receives a message Throws error.

Implementation

@override
Future<MessageEnvelope?> peek(String? correlationId) async {
  MessageEnvelope? message;
  // Pick a message
  if (_messages.isNotEmpty) {
    message = _messages[0];
  }

  if (message != null) {
    logger.trace(message.correlation_id, 'Peeked message %s on %s',
        [message, toString()]);
  }

  return message;
}