[rabbitmq-discuss] erlang client API: transactions

Ben Hood 0x6e6562 at gmail.com
Tue Sep 23 13:00:53 BST 2008


Valentino,

On Tue, Sep 23, 2008 at 3:24 AM, Valentino Volonghi <dialtone at gmail.com> wrote:
> and I implemented ack and tx_commit/tx_select like this:
>
> ack({_Connection, Channel, _Ticket}, DeliveryTag) ->
>     BasicAck = #'basic.ack'{delivery_tag = DeliveryTag, multiple =
> false},
>     ok = amqp_channel:cast(Channel, BasicAck).

This duplicates the ack/2 function in lib_amqp.

>
> tx_select({_Connection, Channel, _Ticket}) ->
>     ok = amqp_channel:cast(Channel, #'tx.select'{}).
>
> tx_commit({_Connection, Channel, _Ticket}) ->
>     ok = amqp_channel:cast(Channel, #'tx.commit'{}).

tx.select/tx.commit are synchronous commands, so you have to use
amqp_channel:call/2 instead of amqp_channel:cast/2

This should really go into lib_amqp - I'll add this as an improvement.

Also, tickets/realms are deprecated and have been removed from the
mainline client code.


>
> Unfortunately when I try to run this code, during the forwarding I get
> the following exception:
>
> =ERROR REPORT==== 22-Sep-2008::19:23:11 ===
> ** Generic server <0.150.0> terminating
> ** Last message in was {method,{'tx.select_ok'},none}
> ** When Server state == {channel_state,1,<0.146.0>,<0.148.0>,<0.151.0>,
>                             #Fun<amqp_network_driver.do.2>,
>                             #Fun<amqp_network_driver.do.3>,
>                             #Fun<amqp_network_driver.close_channel.1>,
>                             {[],[]},
>                             {[],[]},
>                             {dict,0,16,16,8,80,48,
>                                 {[],[],[],[],[],[],[],[],[],[],[],[],
> [],[],[],
>                                  []},
>                                 {{[],[],[],[],[],[],[],[],[],[],[],[],
> [],[],
>                                   [],[]}}},
>                             false,undefined,
>                             {dict,0,16,16,8,80,48,
>                                 {[],[],[],[],[],[],[],[],[],[],[],[],
> [],[],[],
>                                  []},
>                                 {{[],[],[],[],[],[],[],[],[],[],[],[],
> [],[],
>                                   [],[]}}}}
> ** Reason for termination ==
> ** {{badmatch,{empty,{[],[]}}},
>     [{amqp_channel,rpc_bottom_half,2},
>      {gen_server,handle_msg,5},
>      {proc_lib,init_p,5}]}
>
> Which clearly means that I badly matched somewhere... my best guess is
> the tx_select/tx_commit
> functions but then how should I fix them? (sorry for this newb
> question).

Please see the fix for this in my repsonse to Edwin's mail.

HTH,

Ben




More information about the rabbitmq-discuss mailing list