.net-corerabbitmqeasynetq

why Just one of two message is delivered in rabbitmq?


I am trying to connect two applications using RabbitMQ (EasyNetQ) together. I am using the Send/Receive pattern. So Application (A) will send a command to Application (B) and Application (B) will send the result after the process.

But just 50% of messages are always delivered to Application (B). This is my RabbitMQ Panel graph. As you can see, only the Message with the delivered graph (light blue) can be processed in Application (B) and the other is just consumed.

enter image description here

Should I change any configuration on my messages or my application connection to ensure all messages will be delivered?

It may be useful that I test My sender without any consumer and all the messages were received in my RabbitMQ but when I Ran my consumers all of my messages were deleted from the queue without any process in my consumer service.

Update:

So, I found another clue. inside the EasyNetQ_Default_Error_Queue there is an error for each failed Message:

No handler found for message type TestCommand\n at EasyNetQ.Consumer.HandlerCollection.GetHandler

It looks like my handler will be removed


Solution

  • So finally I found the problem. So, it was registering both the request handler and the Receiver function on a single type simultaneously. Like:

    bus.RPC.ResponseAsync<TCommand, TResult>(someHandler);
    bus.SendReceive.ReceiveAsync(queueName, registration =>
            {
                registration.Add<TCommand>(async (message, token) =>
                {
                    await handler(message, token);
                }); 
            });