[rabbitmq-discuss] How to catch RESOURCE_LOCKED exceptions in erlang client
Tim Watson
tim at rabbitmq.com
Fri Aug 16 09:36:14 BST 2013
On 16 Aug 2013, at 09:30, Tim Watson wrote:
Erm - quick errata: you also need
> 2. handle "exit signals" from other processes in the same way, linking or monitoring, then dealing with exits in handle_info
>
> init(Config) ->
> {ok, Conn} = amqp_connection:start(parse_config(Config)),
> {ok, Chan} = amqp_connection:open_channel(Conn),
link(Chan),
> {ok, #state{ connection = Conn, channel = Chan }}.
>
otherwise you won't get the {'EXIT', _, _} tuple if/when the channel process exits. With monitors it'd look like this:
init(Config) ->
{ok, Conn} = amqp_connection:start(parse_config(Config)),
{ok, Chan} = amqp_connection:open_channel(Conn),
erlang:monitor(process, Chan),
{ok, #state{ connection = Conn, channel = Chan }}.
%% ...
handle_info({'DOWN', _Ref, process, Pid, Reason}, State) ... etc
Cheers,
Tim
More information about the rabbitmq-discuss
mailing list