[rabbitmq-discuss] trying to figure out erlando

Matthew Sackman matthew at rabbitmq.com
Sun May 22 22:36:26 BST 2011


On Sun, May 22, 2011 at 04:29:34PM -0500, Jon Brisbin wrote:
> Building on this, how do I translate what's in the blog post w.r.t.
> error_m so I get the behaviour of always doing an
> amqp_channel:close(Chan) no matter what happens in my publish step
> (right after the open_channel)?

with_channel(AMQPParams, Fun) ->
    ErrorT = error_t:new(identity_m),
    do([ErrorT || {ok, Conn} <- amqp_connection:start(AMQPParams),
                  {ok, Chan} <- amqp_connection:open_channel(Conn),
                  {ok, Res}  <- return(Fun(Chan)),
                  ok <- amqp_channel:close(Chan),
                  Res
       ]).

Matthew


More information about the rabbitmq-discuss mailing list