I'm trying to implement RabbitMQ Request-Response pattern.
My goal is that there would be always one consumer that listens to a queue and replies to messages.
So I've set the server up by:
var consumer = new EventingBasicConsumer(channel);
channel.BasicConsume(queue: 'listensToThisQueue',
noAck: true,
consumer: consumer);
consumer.Received += (model, ea) =>
{
// Replying to client
channel.BasicPublish(exchange: '',
routingKey: routingKey,
basicProperties: props,
body: message);
// Basic ack
channel.BasicAck(deliveryTag: incomingDeliveryTag,
multiple: false);
}
Everything actually works fine:
- Client sends first message
- Server receive and reply
- Client gets the message
The only problem is that after finshing Received
method (After executing BasicAck
) - Consumer stops listening to listenToQueue
(I actually see 0 consumers on this queue in the UI management).
Why is that ?