[rabbitmq-discuss] Implementing an RPC backend

Ben Hood 0x6e6562 at gmail.com
Sun Jul 8 11:49:25 BST 2007


> I debugged the route method in rabbit_exchange, which does a mnesia
> lookup of the replyTo routing key:
>
> Handlers = case rabbit_misc:clean_read({binding, BindingKey}) of
>                    {error, not_found} ->
>                        handlers_for_missing_binding_record(X, RoutingKey);
>                    {ok, #binding{handlers = H}} ->
>                        H
>                end,
>
> This returns [], so it seems to be at that point that the message is
> unroutable. I found this last night, so I'll have a look to see what
> the contents of the binding table in mnesia is. I tried initially with
> TV, but it's difficult to see the actual content with that. I'll try
> using the API.

I've found the problem why the mnesia lookup wasn't returning anything
although the there was a binding for the reply queue that the RPC set.

Because I called

@Override public void handleDelivery(AMQP.Basic.Deliver method,
AMQP.BasicProperties properties, byte[] body) throws IOException {

            channel.basicPublish(ticket,method.exchange,
properties.replyTo, true, true,properties,"bar".getBytes());

}

The resulting mnesia lookup was:

{binding_spec,{resource,<<"localhost">>,exchange,<<x2>>},
                                 <<"amq.q.gen5_nonode at nohost_20070708102701_">>,
                                 []}

where x2 = method.exchange.

But the actual record in the database is

{binding_spec,{resource,<<"localhost">>,exchange,<<>>},
                                 <<"amq.q.gen5_nonode at nohost_20070708102701_">>,
                                 []}

i.e. with no named exchange. Therefore the solution was to use an
empty string for the exchange property when called the publish method:

@Override public void handleDelivery(AMQP.Basic.Deliver method,
AMQP.BasicProperties properties, byte[] body) throws IOException {

            channel.basicPublish(ticket,"", properties.replyTo, true,
true,properties,"bar".getBytes());

}

I imagine this behaviour is described in the spec to some extent as well.




More information about the rabbitmq-discuss mailing list