RabbitMQ Shovel配置Alternate-Exchange

时间:2012-07-31 11:22:11

标签: configuration rabbitmq

我正在尝试使用声明列表为RabbitMQ配置Shovel插件。我已经将远程交换配置为在创建时进行备用交换。

我的问题是我无法获取铲子的配置文件以包含此参数,因此RabbitMQ在启动时崩溃。

这就是我的配置:

[
    {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:guest@172.16.3.162: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}
                ]}
            ]
        }]
    }
].

问题出在目标交换机上,名为my-exchange-topic。如果我取出声明部分,那么配置文件可以正常工作。

这是错误:

= INFO REPORT ==== 31-Jul-2012 :: 12:15:25 ===     应用:rabbitmq_shovel     退出:{{invalid_shovel_configuration,call_stats_shovel,                  {invalid_parameter_value,目的地,                      {unknown_fields, 'exchange.declare',                          [alternate_exchange]}}},              {rabbit_shovel,启动,[正常,[]]}}     类型:永久

如果我将alternate_exchange部分从声明中删除,我会在RabbitMQ Web管理中遇到此错误:

  

{{关机,        {server_initiated_close,406,            &lt;&lt;“PRECONDITION_FAILED - 不等效arg'alternate-exchange'for交换'my-exchange-topic'在vhost'blah'中:   收到没有但是当前是'longstr'“&gt;&gt;}}类型的'alt'值,   {gen_server,打电话,        并[d 0.473.0&gt;中         {呼叫,             { 'exchange.declare',0,&LT;&LT; “我的交换话题” &GT;&GT;,&LT;&LT; “主题” &GT;&GT;,假                 真,假FALSE,FALSE,[]},             无,&LT; 0.444.0&GT;},         无穷]}}

2 个答案:

答案 0 :(得分:1)

对于任何想要如何配置需要其他参数的交换和队列的人,您可以这样做:

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

你可以用队列做类似的事情:

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

答案 1 :(得分:0)

为了澄清上面的评论,如果是exchange2exchange铲,配置将是:

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