abandon method

  1. @override
Future abandon(
  1. MessageEnvelope message

Returnes message into the queue and makes it available for all subscribers to receive it again. This method is usually used to return a message which could not be processed at the moment to repeat the attempt. Messages that cause unrecoverable errors shall be removed permanently or/and send to dead letter queue.

  • message a message to return. Return (optional) Future that receives an null for success. Throws error


Future abandon(MessageEnvelope message) async {
  if (message.getReference() == null) {
    return null;

  // Get message from locked queue
  int lockedToken = message.getReference();
  var lockedMessage = _lockedMessages[lockedToken];
  if (lockedMessage != null) {
    // Remove from locked messages

    // Skip if it is already expired
    if (lockedMessage.expirationTime!.millisecondsSinceEpoch <=
        DateTime.now().toUtc().millisecondsSinceEpoch) {
      return null;
  // Skip if it absent
  else {
    return null;

  logger.trace(message.correlation_id, 'Abandoned message %s at %s',
      [message, toString()]);

  return send(message.correlation_id, message);