I am trying to configure a header exchange and some shovels using 'rabbitmq.cfg'. In the shovel configuration, I declare a header exchange, a queue for the shovel, and would like to add a binding rule so that messages with a given header are routed into the shovel queue. How can I declare the binding rule for exchange->queue for a given header value? It's trivial to do through the web admin, but seemingly impossible through the rabbitmq.cfg. I've tried many variations without success, and searched all over the web without finding an example. Please advise.

Search Discussions

  • Matthew Sackman at Nov 10, 2011 at 5:31 pm
    Hi Tom,
    On Thu, Nov 10, 2011 at 07:23:19AM -0800, Tom Cellucci wrote:
    I am trying to configure a header exchange and some shovels using
    'rabbitmq.cfg'. In the shovel configuration, I declare a header
    exchange, a queue for the shovel, and would like to add a binding rule
    so that messages with a given header are routed into the shovel queue.
    How can I declare the binding rule for exchange->queue for a given
    header value? It's trivial to do through the web admin, but seemingly
    impossible through the rabbitmq.cfg. I've tried many variations
    without success, and searched all over the web without finding an
    example. Please advise.
    Which version of RabbitMQ are you using? "rabbitmq.cfg" isn't a file
    name that I recognise - I think you mean "rabbitmq.config", and indeed
    that's the file name that the shovel README talks about:
    http://hg.rabbitmq.com/rabbitmq-shovel/file/b9f4e6dc4fa3/README

    The bind will look something like:

    {'queue.bind',
    [{exchange, <<"my_exchange">>},
    {queue, <<"my_queue">>},
    {arguments, [{"x-match", longstr, "any"},
    {"headerName", longstr, "headerValue"},
    {"otherHeaderName", longstr, "otherHeaderValue"}]}]}

    I think.

    Matthew
  • Matthew Sackman at Nov 10, 2011 at 5:42 pm
    Hi Tom,
    On Thu, Nov 10, 2011 at 05:31:26PM +0000, Matthew Sackman wrote:
    Which version of RabbitMQ are you using? "rabbitmq.cfg" isn't a file
    name that I recognise - I think you mean "rabbitmq.config", and indeed
    that's the file name that the shovel README talks about:
    http://hg.rabbitmq.com/rabbitmq-shovel/file/b9f4e6dc4fa3/README

    The bind will look something like:

    {'queue.bind',
    [{exchange, <<"my_exchange">>},
    {queue, <<"my_queue">>},
    {arguments, [{"x-match", longstr, "any"},
    {"headerName", longstr, "headerValue"},
    {"otherHeaderName", longstr, "otherHeaderValue"}]}]}

    I think.
    That will work if the binding is being created on an endpoint which is
    not a "direct" connection. Otherwise, you need to ensure the keys and
    values are binaries. There is a bug open for this - it's a mistake in
    the erlang client which the shovel uses, but alas it's not been fixed
    yet. So if in doubt, use something like:

    {'queue.bind',
    [{exchange, <<"my_exchange">>},
    {queue, <<"my_queue">>},
    {arguments, [{<<"x-match">>, longstr, <<"any">>},
    {<<"headerName">>, longstr, <<"headerValue">>},
    {<<"otherHeaderName">>, longstr, <<"otherHeaderValue">>}]}]}


    Matthew
  • Tom Cellucci at Nov 11, 2011 at 12:28 am
    Thanks to Matt for the help; I was able to get a queue binding configured per his advice. Now I'd like to configure an exchange binding, which sadly is not working like I'd hoped. Here's what I have:

    {'exchange.declare', [{exchange, <<"events_forwarding_exchange">>}, {type, <<"headers">>}, durable]},
    {'exchange.declare', [{exchange, <<"events_local_exchange">>}, {type, <<"topic">>}, durable]},
    {'queue.declare', [{queue, <<"dc1_events">>}, durable]},
    {'queue.bind', [
    {exchange, <<"events_forwarding_exchange">>},
    {queue, <<"dc1_events">>},
    {arguments, [
    {"route_to_dc1", longstr, "true"}
    ]}
    ]},
    {'exchange.bind', [
    {exchange, <<"events_forwarding_exchange">>},
    {exchange, <<"events_local_exchange">>},
    {arguments, [
    {"x-match", longstr, "any"},
    {"route_to_local", longstr, "true"},
    {"route_to_dc2", longstr, "true"}
    ]}
    ]}

    With the above configuration, the broker fails to start and emits the following error:

    =INFO REPORT==== 10-Nov-2011::16:03:35 ===
    application: rabbitmq_shovel
    exited: {{invalid_shovel_configuration,master_events_shovel,
    {invalid_parameter_value,sources,
    {unknown_fields,'exchange.bind',[exchange]}}},
    {rabbit_shovel,start,[normal,[]]}}
    type: permanent

    What's the right way set up an exchange binding in rabbitmq.config? - I am running RabbitMQ 2.6.1.

    Thanks,
    Tom
    On Nov 10, 2011, at 9:27 AM, Matthew Sackman wrote:

    Hi Tom,
    On Thu, Nov 10, 2011 at 07:23:19AM -0800, Tom Cellucci wrote:
    I am trying to configure a header exchange and some shovels using
    'rabbitmq.cfg'. In the shovel configuration, I declare a header
    exchange, a queue for the shovel, and would like to add a binding rule
    so that messages with a given header are routed into the shovel queue.
    How can I declare the binding rule for exchange->queue for a given
    header value? It's trivial to do through the web admin, but seemingly
    impossible through the rabbitmq.cfg. I've tried many variations
    without success, and searched all over the web without finding an
    example. Please advise.
    Which version of RabbitMQ are you using? "rabbitmq.cfg" isn't a file
    name that I recognise - I think you mean "rabbitmq.config", and indeed
    that's the file name that the shovel README talks about:
    http://hg.rabbitmq.com/rabbitmq-shovel/file/b9f4e6dc4fa3/README

    The bind will look something like:

    {'queue.bind',
    [{exchange, <<"my_exchange">>},
    {queue, <<"my_queue">>},
    {arguments, [{"x-match", longstr, "any"},
    {"headerName", longstr, "headerValue"},
    {"otherHeaderName", longstr, "otherHeaderValue"}]}]}

    I think.

    Matthew
  • Matthias Radestock at Nov 11, 2011 at 8:44 am
    Tom,
    On 11/11/11 00:28, Tom Cellucci wrote:
    I'd like to configure an exchange binding, which sadly is not
    working like I'd hoped.
    [...]
    {'exchange.bind', [
    {exchange,<<"events_forwarding_exchange">>},
    {exchange,<<"events_local_exchange">>},
    {arguments, [
    {"x-match", longstr, "any"},
    {"route_to_local", longstr, "true"},
    {"route_to_dc2", longstr, "true"}
    ]}
    ]}

    With the above configuration, the broker fails to start and emits the following error:

    =INFO REPORT==== 10-Nov-2011::16:03:35 ===
    application: rabbitmq_shovel
    exited: {{invalid_shovel_configuration,master_events_shovel,
    {invalid_parameter_value,sources,
    {unknown_fields,'exchange.bind',[exchange]}}},
    {rabbit_shovel,start,[normal,[]]}}
    type: permanent
    The field names need to match what is in the spec. See
    http://www.rabbitmq.com/amqp-0-9-1-reference.html#exchange.bind - so
    instead of having two 'exchange' fields you need one 'destination' and
    one 'source' field.

    Matthias.
  • Tom Cellucci at Nov 14, 2011 at 7:22 pm
    While the description may have been available in the spec, I suppose it was lost on me that the configuration file itself is somehow an implementation of that spec. So a couple follow up questions:

    * Do all the names / parameters in the specification correspond precisely with syntax in rabbitmq.config?

    * If Exchange to Exchange Bindings are listed in the "extensions" section of the RabbitMQ documentation here: http://www.rabbitmq.com/extensions.html (presumedly non-standard), why would the feature also be present in the specification link you provided?

    * A 'how-to' showing exchange-to-exchange binding in the shovel pages would be golden; seems it would be a fairly common scenario.

    -Tom
    On Nov 11, 2011, at 12:44 AM, Matthias Radestock wrote:

    Tom,
    On 11/11/11 00:28, Tom Cellucci wrote:
    I'd like to configure an exchange binding, which sadly is not
    working like I'd hoped.
    [...]
    {'exchange.bind', [
    {exchange,<<"events_forwarding_exchange">>},
    {exchange,<<"events_local_exchange">>},
    {arguments, [
    {"x-match", longstr, "any"},
    {"route_to_local", longstr, "true"},
    {"route_to_dc2", longstr, "true"}
    ]}
    ]}

    With the above configuration, the broker fails to start and emits the following error:

    =INFO REPORT==== 10-Nov-2011::16:03:35 ===
    application: rabbitmq_shovel
    exited: {{invalid_shovel_configuration,master_events_shovel,
    {invalid_parameter_value,sources,
    {unknown_fields,'exchange.bind',[exchange]}}},
    {rabbit_shovel,start,[normal,[]]}}
    type: permanent
    The field names need to match what is in the spec. See http://www.rabbitmq.com/amqp-0-9-1-reference.html#exchange.bind - so instead of having two 'exchange' fields you need one 'destination' and one 'source' field.

    Matthias.
  • Matthias Radestock at Nov 14, 2011 at 7:40 pm
    Tom,
    On 14/11/11 19:22, Tom Cellucci wrote:
    * Do all the names / parameters in the specification correspond
    precisely with syntax in rabbitmq.config?
    Yes, modulo syntactic substitutions to make names etc more erlang-ish.
    Specifically '-' is mapped to '_'.
    * If Exchange to Exchange Bindings are listed in the "extensions"
    section of the RabbitMQ documentation here:
    http://www.rabbitmq.com/extensions.html (presumedly non-standard),
    why would the feature also be present in the specification link you
    provided?
    The reference guide includes rabbit's protocol extensions. It says so at
    the top, though perhaps that could be clearer.
    * A 'how-to' showing exchange-to-exchange binding in the shovel pages
    would be golden; seems it would be a fairly common scenario.
    The shovel documentation could certainly be improved.

    Would you consider publishing a blog post after you've got it all
    working? Looks like your use of the shovel is a bit more complex than
    most, so I am sure other rabbit users would find it interesting.

    Regards,

    Matthias.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprabbitmq-discuss @
categoriesrabbitmq
postedNov 10, '11 at 3:23p
activeNov 14, '11 at 7:40p
posts7
users3
websiterabbitmq.com
irc#rabbitmq

People

Translate

site design / logo © 2021 Grokbase