Hello.

I encountered bug in consistent-hash-exchange used in exchange-exchange
routing.
Let's consider following routing:

exchange A of type topic
exchange B of type consistent-hash-exchange
exchange C of type consistent-hash-exchange

binding A -> B with routing key "b.#"
binding A -> C with routing key "c.#"

If there are queues bound to exchanges B and C, everything works as
expected.

If there aren't queues bound to C, but there are queues bound to B then
message with routing key "c.x" sent to exchange A is routed to one of the
B's queues. It should be discarded instead or cause NO-ROUTE or
NO_CONSUMERS (message flag dependent).

Regards
Wojciech Durczy?ski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20111208/8c117216/attachment.htm>

Search Discussions

  • Matthew Sackman at Dec 8, 2011 at 3:02 pm

    On Thu, Dec 08, 2011 at 06:34:24AM -0800, Wojciech Durczy?ski wrote:
    Let's consider following routing:

    exchange A of type topic
    exchange B of type consistent-hash-exchange
    exchange C of type consistent-hash-exchange

    binding A -> B with routing key "b.#"
    binding A -> C with routing key "c.#"

    If there are queues bound to exchanges B and C, everything works as
    expected.

    If there aren't queues bound to C, but there are queues bound to B then
    message with routing key "c.x" sent to exchange A is routed to one of the
    B's queues. It should be discarded instead or cause NO-ROUTE or
    NO_CONSUMERS (message flag dependent).
    Agreed. I've just knocked up the following test, and you're right. It's
    clearly wrong. Sorry about that. I'll get it fixed and it should be in
    the next release.

    -module(test).
    -compile([export_all]).

    -include_lib("amqp_client/include/amqp_client.hrl").

    test_consistent_hash() ->
    A = <<"A">>, B = <<"B">>, C = <<"C">>, Q = <<"my_queue">>,
    {ok, Conn} = amqp_connection:start(#amqp_params_network{}),
    {ok, Chan} = amqp_connection:open_channel(Conn),
    #'queue.declare_ok' {} = amqp_channel:call(Chan, #'queue.declare'{ queue = Q }),
    #'exchange.declare_ok'{} =
    amqp_channel:call(
    Chan, #'exchange.declare'{ exchange = A, type = <<"topic">> }),
    #'exchange.declare_ok'{} =
    amqp_channel:call(
    Chan, #'exchange.declare'{ exchange = B, type = <<"x-consistent-hash">> }),
    #'exchange.declare_ok'{} =
    amqp_channel:call(
    Chan, #'exchange.declare'{ exchange = C, type = <<"x-consistent-hash">> }),
    #'exchange.bind_ok'{} = amqp_channel:call(
    Chan, #'exchange.bind'{ source = A, destination = B,
    routing_key = <<"b.#">> }),
    #'exchange.bind_ok'{} = amqp_channel:call(
    Chan, #'exchange.bind'{ source = A, destination = C,
    routing_key = <<"c.#">> }),
    #'queue.bind_ok'{} = amqp_channel:call(
    Chan, #'queue.bind'{ queue = Q, exchange = B,
    routing_key = <<"10">> }),
    Msg = #amqp_msg { props = #'P_basic'{}, payload = <<"hello">> },
    Publish = #'basic.publish'{ routing_key = <<"c.foo">>, exchange = A },
    amqp_channel:call(Chan, Publish, Msg),
    timer:sleep(1000),
    io:format("~p~n", [amqp_channel:call(Chan, #'queue.declare'{ queue = Q })]),
    amqp_connection:close(Conn).

    Matthew
  • Wojciech Durczyński at Dec 8, 2011 at 3:22 pm
    Could you provide a quick patch for this bug?
    I'd be very grateful for
    modified rabbitmq_consistent_hash_exchange-2.7.0.ez file.
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20111208/37677cf3/attachment.htm>
  • Matthew Sackman at Dec 8, 2011 at 3:28 pm

    On Thu, Dec 08, 2011 at 03:02:10PM +0000, Matthew Sackman wrote:
    Agreed. I've just knocked up the following test, and you're right. It's
    clearly wrong. Sorry about that. I'll get it fixed and it should be in
    the next release.
    Fixed. The fix is at
    http://hg.rabbitmq.com/rabbitmq-consistent-hash-exchange/rev/5531ff99f00f

    If you're happy compiling from source then just
    pulling/updating/compiling will do the trick, otherwise, I hear the next
    release may not be too long away (though in Rabbit terms, that can be
    anything from days to months), so you might prefer to wait for that.

    Thanks for the report.

    Matthew

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprabbitmq-discuss @
categoriesrabbitmq
postedDec 8, '11 at 2:34p
activeDec 8, '11 at 3:28p
posts4
users2
websiterabbitmq.com
irc#rabbitmq

People

Translate

site design / logo © 2022 Grokbase