Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Never ending messages with RabbitMQ

We are using MassTransit(3.5.2) together with RabbitMQ(3.6.6). We are having a problem with a message that never gets removed from the queue (even if we have read and consumed the message). To read from the queue we have implemented an IConsumer class.

The only thing we are doing is closing the sender (abrupt). After that the message never gets acknowledged and rabbitmq is continuing to send the same message to our consumer all the time.

Have anyone else got the same problem and how did you solve this issue?

:: Update from comments ::

We had already checked the log files and it says: "closing AMQP connection <0.18285.1> ([::1]:57008 -> [::1]:5672): client unexpectedly closed TCP connection ". That doesnt feel that wierd since i am actually closing the tcp connection unexpectedly with killing the .exe file :)

Regarding the log files from masstransit we have also done that and we do not get any error, we only gets two debug messages. One that we have received and one that we are sending the result. DEBUG 47 MassTransit.Messages - RECEIVE rabbitmq://localhost/[VirtualHost]/[ConsumerName] N/A ContractCommand CommandConsumer(00:00:00.0364932) DEBUG 30 MassTransit.Messages - SEND rabbitmq://localhost/[VirtualHost]/bus-[ComputerName]-[Sende‌​rName].Server.vshost‌​-4bayyydsf9rfs3qzbdk‌​gx8bbr1?durable=fals‌​e&autodelete=true d0700000-762f-c85b-f03a-08d4679c39d4 Result

One observation that I have made in my consumer is that at the same time as I am force closing my sender I get an MessageNotConfirmedException followed by some AlreadyClosedException from RabbitMQ. And it's after that we get in the infinite loop when MT does not set the ACK/NACK. (and in the infinite loop I do not get any MessagenNotConfirmedException). Also for my consumer to properly work again I need to restart my consumer then it will be ACK/NACKed.

MessageNotConfirmedMessage: "'MassTransit.RabbitMqTransport.MessageNotConfirmedException‌​' in mscorlib.dll Additional information: rabbitmq://localhost/[VirtualHost]/bus-[ComputerName]-[Servi‌​ce].Server.vshost-4b‌​ayyydsf9rfsf3ybdkgxg‌​5h8b => The message was not confirmed by RabbitMQ 'RabbitMQ.Client.Exceptions.AlreadyClosedException' Additional information: Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=404, text="NOT_FOUND - no exchange 'bus-[ComputerName]-[ServiceName].Server.vshost-4bayyydsf9rf‌​s3qzbdkgx8bbr1' in vhost '[VirtualHost]'", classId=60, methodId=40, cause=

like image 271
Mikael Johansson Avatar asked Mar 09 '17 11:03

Mikael Johansson


People also ask

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.

Is RabbitMQ persistent?

The short answer is yes: RabbitMQ supports persistence of messages. For this to happen the message must be persistent (set in the client) and the queue(s) that it is routed to must be Durable.

What happens when RabbitMQ queue is full?

The default behaviour for RabbitMQ when a maximum queue length or size is set and the maximum is reached is to drop or dead-letter messages from the front of the queue (i.e. the oldest messages in the queue).

How many messages can RabbitMQ handle per second?

As you can see, IronMQ can handle a sustained enqueue rate of ~18,000 - ~19,000 messages per second and a consume rate of ~4K per second on a single queue. RabbitMQ can handle ~950 per second in and out.


1 Answers

I have updated our code to use MassTransit 3.5.7 and after that I have not been able to reproduce this issue.

like image 112
Mikael Johansson Avatar answered Sep 28 '22 03:09

Mikael Johansson