1
votes

I have pre-setup RabbitMQ configuration: Exchange-1, Queue-1 with binding using Routing Key "notifications.info". I would like to connect to the existing Queue-1 using MassTransit.

var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
{
    cfg.Host("rabbitmq://guest:guest@localhost");


    cfg.ReceiveEndpoint("Queue-1", e =>
    {
        e.ConfigureConsumeTopology = false;

        e.Consumer<EventConsumer>();
        e.Bind("Exchange-1", x =>
        {
            x.Durable = false;
            x.AutoDelete = false;
            x.ExchangeType = ExchangeType.Topic;
            x.RoutingKey = "notifications.info";
        });
    });
});

Error:

The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406,
text='PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'Queue-1' in vhost '/':
received 'true' but current is 'false'', classId=40, methodId=10

MassTransit creates exchange `Queue-1'. I don't need to create the extra entities at RabbitMQ. Any options to disable it?

Useful info

bash-5.0# rabbitmqctl list_exchanges name type durable auto_delete internal arguments policy
name    type    durable auto_delete     internal        arguments       policy
Exchange-1      topic   false   false   false   []
Queue-1 fanout  false   false   false   []

bash-5.0# rabbitmqctl list_queues name durable auto_delete arguments exclusive
name    durable auto_delete     arguments       exclusive
Queue-1 false   false   [{"x-queue-type","classic"}]    false
1

1 Answers

1
votes

There are no options to disable it, it's how MassTransit configures the topology for receive endpoints (exchange and queue with the same name).

The error is actually because the exchange already exists and doesn't match your receive endpoint configuration.

This small change should fix the error:

cfg.ReceiveEndpoint("Queue-1", e =>
{
    e.ConfigureConsumeTopology = false;

    // since your queue is non-durable
    e.Durable = false;

    e.Consumer<EventConsumer>();
    e.Bind("Exchange-1", x =>
    {
        x.Durable = false;
        x.AutoDelete = false;
        x.ExchangeType = ExchangeType.Topic;
        x.RoutingKey = "notifications.info";
    });
});