[rabbitmq-discuss] Erlang Client RPC issues

Chris Jimison cjimison at gmail.com
Wed Dec 4 06:06:52 GMT 2013

Hey all,

I am running an Erlang server and I want to make an RPC call to another server that may or may not be running.

I am running the following code:

* Connection is a valid amqp connection

    Client = amqp_rpc_client:start(Connection, <<“info_queue”>>),
    Reply = amqp_rpc_client:call(Client, <<"info">>),

Two questions:

1) I noticed in the amqp_rpc_client.erl that it is not handling #’basic.return’{} messages.  I added a call to:
amqp_channel:register_return_handler(Channel, self()),

in the init function and a handle_info call:

handle_info({#'basic.return'{}, Content}, State = #state{continuations = Conts, channel = _Channel}) ->
    #amqp_msg{props = #'P_basic'{correlation_id = Id}, payload = _Payload} = Content,
    From = dict:fetch(Id, Conts),
    gen_server:reply(From, basic_return),
    {noreply, State};

and that seems to work well.  I am very new to RabbitMQ and I am not really sure if this is going to break something very badly.  Is there a reason amqp_rpc_client is not a return_handler?

2) When I call amqp_rpc_client:stop I am getting error messages (with our without my changes) about:


It seams to me that when the Channel created in amqp_rpc_client is shutdown, the amqp_direct_consumer is getting the ‘DOWN’ message and returning {error, {consumer_died, Info}, C};

Does this sound correct that calling stop on an amqp_rpc_client should be generating so many errors?  Is there some cleaner way I should be stopping the amqp_rpc_client?

I tried moving the amqp_channel:close call into the handle_call(stop, _From, State) function and that did clean things up a bit.  But I am still getting a:

gen_server <0.19536.1> terminated with reason: {error,{consumer_died,normal}}

Thanks for any insights and help!


Mac OS X: 10.9
RabbitMQ server 3.2.1
rabbitmq-erlang-client github fork, based on the rabbitmq_v3_2_1 git tag

- Chris

More information about the rabbitmq-discuss mailing list