<div dir="ltr">I believe this is coming from the Erlang client, in amqp_channel:rpc_bottom_half/2. I can't tell you why your program is doing this, only where the error message originates. It seems to be happening in response to receiving a tx.select_ok, AFAICS.<br>
<br>If you look at the code for rpc_bottom_half (reproduced at the end of this email for convenience), the line <br><br><span style="font-family: courier new,monospace;">{{value, {From,_}}, NewRequestQueue} = queue:out(RequestQueue)</span><br>
<br>will create the error message you are seeing if RequestQueue is empty. This can clearly be seen in the shell:<br><br><span style="font-family: courier new,monospace;">1> EmptyQ = queue:new().</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{[],[]}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">2> {{value, {From,_}}, NewRequestQueue} = queue:out(EmptyQ).</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">** exception error: no match of right hand side value </span><b style="font-family: courier new,monospace;">{empty,{[],[]}}</b><br><br>I don't know if this is a bug or one of those "can't happen" things that just didn't give a nice error message. I suspect the latter, because the code just cannot continue without the value of "From" to send a reply to. Why should the function have been called with a reply if the reply queue is empty? Something's wrong somewhere.<br>
<br>In addition, maybe I am too tired to see straight, but this looks really suspect:<br><br><span style="font-family: courier new,monospace;"> catch case queue:head(NewRequestQueue) of</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> empty -></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ok;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {NewFrom,Method} -></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> Do2(Writer,Method)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> end,</span><br><br>This is because queue:head/1 exits when it is empty and does not return 'empty', so the catch will return an EXIT:<br><br><span style="font-family: courier new,monospace;">1> catch queue:head(queue:new()).</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{'EXIT',{empty,[{queue,head,[{[],[]}]},</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {erl_eval,do_apply,5},</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {erl_eval,expr,5},</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {shell,exprs,6},</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {shell,eval_exprs,6},</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {shell,eval_loop,3}]}}</span><br style="font-family: courier new,monospace;">
<br>I think this should be <br><br><span style="font-family: courier new,monospace;"> catch case queue:head(NewRequestQueue) of</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {'EXIT', {empty,_}} -></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ok;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {NewFrom,Method} -></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> Do2(Writer,Method)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> end,<br><br></span>Maybe an empty queue is one of those things that should never happen, but like I said, I am really tired...<br><br><br><b>Code reproduced from amqp_channel.erl</b><br>
<br><span style="font-family: courier new,monospace;">rpc_bottom_half(Reply, State = #channel_state{writer_pid = Writer,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> rpc_requests = RequestQueue,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> do2 = Do2}) -></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <b>{{value, {From,_}}, NewRequestQueue} = queue:out(RequestQueue),</b></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> gen_server:reply(From, Reply),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> catch case queue:head(NewRequestQueue) of</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> empty -></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ok;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {NewFrom,Method} -></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> Do2(Writer,Method)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> end,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> NewState = State#channel_state{rpc_requests = NewRequestQueue},</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {noreply, NewState}.</span><br><br><br><div class="gmail_quote">On Mon, Sep 22, 2008 at 10:24 PM, Valentino Volonghi <span dir="ltr"><<a href="mailto:dialtone@gmail.com">dialtone@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<br>
so I'm trying to add support for transactions to my simple forwarding<br>
application, I started by<br>
implementing the 'commit every 500 messages' in the following way:<br>
<br>
handle_info(#'tx.select_ok'{}, State) -><br>
{noreply, State};<br>
<br>
handle_info(#'tx.commit_ok'{}, State) -><br>
{noreply, State};<br>
<br>
handle_info({#'basic.deliver'{routing_key = RoutingKey,<br>
delivery_tag = DeliveryTag},<br>
#content{payload_fragments_rev = [Payload]}},<br>
State = #shovel_state{local = LocalBroker,<br>
remote = RemoteBroker,<br>
exchange = Exchange,<br>
sent = Sent,<br>
ack = Acks}) -><br>
deliver(State, RoutingKey, DeliveryTag, Payload, LocalBroker,<br>
RemoteBroker, Exchange, Sent, Acks).<br>
<br>
deliver(State, RoutingKey, DeliveryTag, Payload, _LocalBroker,<br>
RemoteBroker, Exchange, 0, []) -><br>
amqp:tx_select(RemoteBroker),<br>
amqp:send_message(RemoteBroker, RoutingKey, Payload, Exchange),<br>
NewState = State#shovel_state{sent=1, ack=[DeliveryTag]},<br>
{noreply, NewState};<br>
<br>
deliver(State, RoutingKey, DeliveryTag, Payload, LocalBroker,<br>
RemoteBroker, Exchange, 499, Acks) -><br>
amqp:send_message(RemoteBroker, RoutingKey, Payload, Exchange),<br>
amqp:tx_commit(RemoteBroker),<br>
lists:foreach(fun(X) -> amqp:ack(LocalBroker, X) end,<br>
[DeliveryTag|Acks]),<br>
NewState = State#shovel_state{sent=0, ack=[]},<br>
{noreply, NewState};<br>
<br>
deliver(State, RoutingKey, DeliveryTag, Payload, _LocalBroker,<br>
RemoteBroker, Exchange, Sent, Acks) -><br>
amqp:tx_select(RemoteBroker),<br>
amqp:send_message(RemoteBroker, RoutingKey, Payload, Exchange),<br>
NewState = State#shovel_state{sent=Sent+1, ack=[DeliveryTag|Acks]},<br>
{noreply, NewState}.<br>
<br>
and I implemented ack and tx_commit/tx_select like this:<br>
<br>
ack({_Connection, Channel, _Ticket}, DeliveryTag) -><br>
BasicAck = #'basic.ack'{delivery_tag = DeliveryTag, multiple =<br>
false},<br>
ok = amqp_channel:cast(Channel, BasicAck).<br>
<br>
tx_select({_Connection, Channel, _Ticket}) -><br>
ok = amqp_channel:cast(Channel, #'tx.select'{}).<br>
<br>
tx_commit({_Connection, Channel, _Ticket}) -><br>
ok = amqp_channel:cast(Channel, #'tx.commit'{}).<br>
<br>
Unfortunately when I try to run this code, during the forwarding I get<br>
the following exception:<br>
<br>
=ERROR REPORT==== 22-Sep-2008::19:23:11 ===<br>
** Generic server <0.150.0> terminating<br>
** Last message in was {method,{'tx.select_ok'},none}<br>
** When Server state == {channel_state,1,<0.146.0>,<0.148.0>,<0.151.0>,<br>
#Fun<amqp_network_driver.do.2>,<br>
#Fun<amqp_network_driver.do.3>,<br>
#Fun<amqp_network_driver.close_channel.1>,<br>
{[],[]},<br>
{[],[]},<br>
{dict,0,16,16,8,80,48,<br>
{[],[],[],[],[],[],[],[],[],[],[],[],<br>
[],[],[],<br>
[]},<br>
{{[],[],[],[],[],[],[],[],[],[],[],[],<br>
[],[],<br>
[],[]}}},<br>
false,undefined,<br>
{dict,0,16,16,8,80,48,<br>
{[],[],[],[],[],[],[],[],[],[],[],[],<br>
[],[],[],<br>
[]},<br>
{{[],[],[],[],[],[],[],[],[],[],[],[],<br>
[],[],<br>
[],[]}}}}<br>
** Reason for termination ==<br>
** {{badmatch,{empty,{[],[]}}},<br>
[{amqp_channel,rpc_bottom_half,2},<br>
{gen_server,handle_msg,5},<br>
{proc_lib,init_p,5}]}<br>
<br>
Which clearly means that I badly matched somewhere... my best guess is<br>
the tx_select/tx_commit<br>
functions but then how should I fix them? (sorry for this newb<br>
question).<br>
<br>
- --<br>
Valentino Volonghi aka Dialtone<br>
Now running MacOS X 10.5<br>
Home Page: <a href="http://www.twisted.it" target="_blank">http://www.twisted.it</a><br>
<a href="http://www.adroll.com" target="_blank">http://www.adroll.com</a><br>
<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.9 (Darwin)<br>
<br>
iEYEARECAAYFAkjYU3sACgkQ9Llz28widGUvqACZAaF5i6y0RCeq6S515PPERjsy<br>
09kAoLHg1ohSFpGpDd2SGCe6I2s6Vqw6<br>
=lGsw<br>
-----END PGP SIGNATURE-----<br>
<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
<br>
</blockquote></div><br></div>