Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MassTransit with RabbitMQ: When is a message moved to the error queue

I am using RabbitMQ version 3.0.2 & I see close to 1000 message in Error queue. I want to know

  1. At what point messages are moved to the error queues?
  2. Is there a way to know why a certain message is being moved to an error queue?
  3. Is there any way to move message from error queue to normal queue?

Thank you

like image 456
SharpCoder Avatar asked Dec 11 '13 08:12

SharpCoder


People also ask

What does MassTransit add to RabbitMQ?

MassTransit provides a heavily production tested convention for using RabbitMQ exchanges to route published messages to the subscribed consumers. The structure is CPU and memory friendly, which keeps RabbitMQ happy.

How does RabbitMQ queue work?

The user sends a PDF creation request to the web application. The web application (the producer) sends a message to RabbitMQ that includes data from the request such as name and email. An exchange accepts the messages from the producer and routes them to correct message queues for PDF creation.

Does RabbitMQ lose messages?

RabbitMQ Durable queues are those that can withstand a RabbitMQ restart. If a queue is not durable, all messages will be lost if RabbitMQ is shut down for any reason. For messages to survive restarts, both of these configurations must be true.

How are messages passed in RabbitMQ?

When a consumer (subscription) is registered, messages will be delivered (pushed) by RabbitMQ using the basic. deliver method. The method carries a delivery tag, which uniquely identifies the delivery on a channel. Delivery tags are therefore scoped per channel.


2 Answers

  1. a) they fail to deserialize or b) the consumer throws an exception processing that message five times
  2. Not really... If you peek at the message in the queue, the payload headers might contain a note but I don't think we did that. If you turn logging on (NLog, log4net, etc) you should be able to see the exceptions in your log. You'll have to correlate message ids at that point to figure out exactly why.
  3. There is no built in way via MassTransit. Mostly because there doesn't seem to be a great, generic way to handle this. Everyone wants some process around this. Dru did create a BusDriver app (in the main MT source repo) that could be used to move messages back to the exchange in question. This default behaviour is there so you at least know things have been failing if you don't put in the infrastructure to handle it.
like image 102
Travis Avatar answered Sep 29 '22 08:09

Travis


To add to Travis' answer, During my development I found some other reasons for messages going onto the error queue:

  1. The published message type has no consumer
  2. A SAGA and a consumer are expecting the same concrete message type. Even if you try and differentiate using "Accepts" and ".Selected", both a SAGA and a Consumer should not be programmed to receive the same message type.
like image 31
Paul Avatar answered Sep 29 '22 07:09

Paul