[rabbitmq-discuss] register_confirm_handler using the Erlang client

Simon MacMullen simon at rabbitmq.com
Fri Sep 27 16:56:26 BST 2013


On 27/09/2013 4:39PM, eimu gray wrote:
> Hi,
>     I'm a Rabbit newbie, I use register_confirm_handler/2 to register a
> handler which deals with confirm-related messages, but it didn't receive
> any acks or nacks.
> Then I  add  code1 after amqp_channel:cast(Channel, Publish, Msg), It
> can work. so why? I want to publish msg In the asynchronous mode.
> Thanks!!!!
>
> code1:
> receive
>     Any -> void
> end

The reason is that without "code1" you are publishing a bunch of 
messages and then immediately closing the channel, before the confirms 
have arrived. When you stick that extra receive block in you cause the 
"main" process to hang and not close the channel - as a consequence you 
end up having time to receive the confirms.

Cheers, Simon

-- 
Simon MacMullen
RabbitMQ, Pivotal


More information about the rabbitmq-discuss mailing list