rabbitmqqueuemessage-queuerabbitmqctl

RabbitMQ: Confirm That Message Reached The Queue


I'm new in RabbitMQ and I'm trying to build a robust producer that keep trying to deliver the message

So I need to make sure that the message sent from my producer and placed in the queue. I just need to confirm that it's in the queue 'may not received consumer yet becuse of the size of queue'.

My simple app publisher

    var factory = new ConnectionFactory
    {
         Uri = new Uri($"amqp://{_config.MassTransit.Username}:{_config.MassTransit.Password}@{_config.MassTransit.Host}:{_config.MassTransit.Port}")
    };

    using IConnection connection = factory.CreateConnection();
    using IModel channel = connection.CreateModel();


    channel.BasicPublish(message.ExchangeName, message.RoutingKey, null, 
    Encoding.UTF8.GetBytes(JsonSerializer.Serialize(message)));

So, how can I confirm message in queue in order to avoid redelivery the message?

Thanks in advance.


Solution

  • You are looking for publisher confirms.