kzhen
kzhen

Reputation: 3128

RabbitMQ Shovel config with Alternate-Exchange

I'm trying to configure the Shovel plugin for RabbitMQ with a list of declarations. I have configured my remote exchange to have an alternate-exchange when I created it.

My problem is that I can't get the config file for shovel to include this argument so RabbitMQ crashes upon startup.

This is what my config looks like:

[
    {mnesia, [{dump_log_write_threshold, 100}]},
    {rabbit, [{vm_memory_high_watermark, 0.4}]},
    {rabbitmq_shovel,
        [{shovels,
            [{call_stats_shovel,
                [{sources, [{broker, "amqp://guest:guest@localhost:5672/test"},
                    {declarations,
                        [{'queue.declare', [{queue, <<"incoming">>}, durable]},
                        {'exchange.declare',[{exchange, <<"my-exchange-topic">>},{type, <<"topic">>},durable]},
                        {'queue.bind',[{exchange, <<"my-exchange-topic">>},{queue, <<"incoming">>}]}
                ]}]},
                {destinations, [{broker, "amqp://guest:[email protected]:5672/blah"},
                    {declarations,
                    [
                        {'queue.declare',[{queue, <<"billing">>},durable]},
                        {'exchange.declare',[{exchange, <<"my-exchange-topic">>},{type, <<"topic">>},{alternate_exchange, <<"alt">>}, durable]},
                        {'queue.bind',[{exchange, <<"my-exchange-topic">>},{queue, <<"billing">>},{routing_key, <<"physical">>}]}
                    ]}
                ]},
                {queue, <<"incoming">>},
                {ack_mode, no_ack},
                {publish_properties, [{delivery_mode, 2}]},
                {reconnect_delay, 5}
                ]}
            ]
        }]
    }
].

The problem is on the destination exchange called my-exchange-topic. If I take out the declarations section then the config file works.

This is the error:

=INFO REPORT==== 31-Jul-2012::12:15:25 === application: rabbitmq_shovel exited: {{invalid_shovel_configuration,call_stats_shovel, {invalid_parameter_value,destinations, {unknown_fields,'exchange.declare', [alternate_exchange]}}}, {rabbit_shovel,start,[normal,[]]}} type: permanent

If I leave the alternate_exchange section out of the declaration I get this error in RabbitMQ web management:

{{shutdown, {server_initiated_close,406, <<"PRECONDITION_FAILED - inequivalent arg 'alternate-exchange'for exchange 'my-exchange-topic' in vhost 'blah': received none but current is the value 'alt' of type 'longstr'">>}}, {gen_server,call, [<0.473.0>, {call, {'exchange.declare',0,<<"my-exchange-topic">>,<<"topic">>,false, true,false,false,false,[]}, none,<0.444.0>}, infinity]}}

Upvotes: 1

Views: 2452

Answers (2)

spier
spier

Reputation: 2752

For clarification of the comment above, in case of an exchange2exchange shovel, the config would be:

{'exchange.declare',[{exchange, <<"my-exchange-topic">>},{type, <<"topic">>}, durable, {arguments, [{<<"alternate-exchange">>, longstr, <<"name-of-your-alternate-exchange">>}]}  ]},

Upvotes: 0

kzhen
kzhen

Reputation: 3128

For anyone looking at how to configure exchanges and queues that require additional arguments you do it like this:

{'exchange.declare',[{exchange, <<"my-exchange-topic">>},{type, <<"topic">>}, durable, {arguments, [{<<"alternate-exchange">>, longstr, <<"alternate-exchange">>}]}  ]},

you can do a similar thing with queues:

{'queue.declare',[{queue, <<"my-queue">>},durable, {arguments, [{<<"x-dead-letter-exchange">>, longstr, <<"dead-letter-queue">>}]}]}

Upvotes: 1

Related Questions