I'm wondering if it is possible to manually Ack or Reject message from the RabbitMQ within the Magento 2 consumer process? What is the default behavior?

1 Answer 1


Let's take first the case of vendor/magento/framework-message-queue/Consumer.php (this is the consumer instance used by most M2 OOTB consumers). Check the method process() and from it go to method getTransactionCallback().

Within this method, the class vendor/magento/framework-amqp/Queue.php is called when using acknowledge() and reject() (in their definition you will find as expected the basic_ack and basic_reject).

In the case of vendor/magento/framework-message-queue/BatchConsumer.php, if you go down the line, you will find usages of the vendor/magento/framework-message-queue/MessageStatusProcessor.php class with its acknowledgeMessages() and rejectMessages() which again point back to the vendor/magento/framework-amqp/Queue.php as described above.

So in conclusion, Magento already uses both mechanisms, depending on a specific logic. Check the methods mentioned above to get a grasp on when each is used.


  • It seems the reject method doesn't work, I'm trying to add $queue->reject($message); return; after vendor/magento/module-asynchronous-operations/Model/MassConsumerEnvelopeCallback.php:103, but messages are still ack-ed. Commented Apr 2, 2021 at 12:16
  • does the code reach your line at least? maybe you are on a different flow
    – Diana
    Commented Apr 2, 2021 at 12:32
  • yes, the code reaches normally, but reject doesn't seem to work Commented Apr 2, 2021 at 15:08
  • uhmm ok, that's weird, really weird. i mean i can't think of a different reason for implementing reject with basic_reject if not for rejecting messages.
    – Diana
    Commented Apr 2, 2021 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.