Hi all,
during my tests on the AMQP.Net Library (http://amqpnetlite.codeplex.com/) I think I found a problem in the Service Bus AMQP protocol support.
Following a simple application (don't see too much the coding style, I replied quickly the problem from a bigger software).
race.TraceLevel = TraceLevel.Frame | TraceLevel.Verbose; Trace.TraceListener = (f, a) => System.Diagnostics.Trace.WriteLine(DateTime.Now.ToString("[hh:ss.fff]") + " " + string.Format(f, a)); string connString = "amqps://<user>:<key>@<namespace>.servicebus.windows.net"; Address address = new Address(connString); Connection conn = new Connection(new Address(connString)); Session session = new Session(conn); SenderLink sender = new SenderLink(session, String.Format("send-link{0}", "q1"),"q1"); Message message = new Message(); message.Properties = new Amqp.Framing.Properties(); message.Properties.Subject = "test"; sender.Send(message, null, null); Thread.Sleep(5000); ReceiverLink receiver = new ReceiverLink(session, String.Format("receive-link{0}", "q1"),"q1"); receiver.SetCredit(5); Message msg = receiver.Receive(); if (msg != null) { receiver.Accept(msg); } sender.Close(); //receiver.Close(); --> I WANT IT COMMENTED :-) session.Close(); conn.Close();
As you can see I open a connection and a session with the node queue (as AMQP named) "q1" on SB and then two links, one to send and one to receive. I send a message then I try to receive it. After this, I "forget" to close the receiver link (I close sender link, session and connection).
If I re-execute the same code, I can send the message and see it into the queue (using Service Bus Explorer) but the receiver.Receive() blocks without receiving message and exit for timeout. The message is still there (as I said I can see it using Service Bus Explorer).
It seems that on Service Bus the receiver link is still alive. However, the only way to reuse the queue is delete and re-create it ! Even if I wait more than 10 minutes it doesn't return to work properly.
I execute same test with Qpid broker and ActiveMQ broker and they work properly. Even if I "forget" to close receiver link first time, the next time I can use the queue to send and receive.
With Qpid broker I see a "detach" message from the broker to tell the client that it forgets to detach it. In this case the broker detaches the link and it will work next time. This message there isn't with ActiveMQ and Service Bus but with the former the queue continues to work with the latter the queue doesn't work anymore.
Following AMQP.Net Library tracing for SB, Qpid broker and ActiveMQ to see raw AMQP messages exchanged between peers. For each broker, there are the messages exchanged for the first and second time. As you can see with Service Bus, the second time, after"attach" message for the receiver there isn't "transfer" message (receiving message from queue).
Service Bus
[03:46.461] SEND AMQP 3 1 0 0
[03:46.481] SEND sasl-init(mechanism:PLAIN,initial-response:006F776E657200657079677642637A49674C546F7554772B756850327733457369334E47356857704D694F565045703058383D,hostname:amqpnetlitetest.servicebus.windows.net)
[03:46.512] RECV AMQP 3 1 0 0
[03:46.569] RECV sasl-mechanisms(sasl-server-mechanisms:[PLAIN,EXTERNAL])
[03:47.307] RECV sasl-outcome(code:0,additional-data:57656C636F6D6521)
[03:47.310] SEND AMQP 0 1.0.0
[03:47.312] SEND (ch=0) open(container-id:d399d18b-9961-4078-8957-4f447ec4bd0c,host-name:amqpnetlitetest.servicebus.windows.net,max-frame-size:16384,channel-max:3)
[03:47.319] SEND (ch=0) begin(next-outgoing-id:4294967293,incoming-window:2048,outgoing-window:2048,handle-max:7)
[03:47.324] SEND (ch=0) attach(name:send-linkq1,handle:0,role:False,source:source(),target:target(address:q1),initial-delivery-count:0)
[03:48.463] RECV AMQP 0 1 0 0
[03:48.534] RECV (ch=0) open(container-id:90829c71582b4d41a94afaffbfba0fff_G12,max-frame-size:16384,channel-max:3,idle-time-out:240000)
[03:48.536] RECV (ch=0) begin(remote-channel:0,next-outgoing-id:1,incoming-window:2048,outgoing-window:2048,handle-max:7)
[03:48.538] RECV (ch=0) attach(name:send-linkq1,handle:0,role:True,source:source(),target:target(address:q1),max-message-size:262144)
[03:48.541] RECV (ch=0) flow(next-in-id:4294967293,in-window:2048,next-out-id:1,out-window:2048,handle:0,delivery-count:0,link-credit:50,available:0,echo:False)
[03:48.547] SEND (ch=0) transfer(handle:0,delivery-id:0,delivery-tag:00000000,message-format:0,settled:True,batchable:True)
[03:53.464] SEND (ch=0) attach(name:receive-linkq1,handle:1,role:True,source:source(address:q1),target:target())
[03:53.467] SEND (ch=0) flow(next-in-id:0,in-window:2048,next-out-id:4294967293,out-window:2047,handle:1,delivery-count:0,link-credit:5)
[03:54.149] RECV (ch=0) attach(name:receive-linkq1,handle:1,role:False,rcv-settle-mode:1,source:source(address:q1),target:target(),initial-delivery-count:0,max-message-size:18446744073709551615)
[03:54.150] RECV (ch=0) transfer(handle:1,delivery-id:0,delivery-tag:E8D09A9CFEA2BF439B91283085E92A8F,message-format:0,more:False,batchable:True)
[03:55.800] SEND (ch=0) disposition(role:True,first:0,settled:True,state:accepted())
[03:55.802] SEND (ch=0) detach(handle:0,closed:True)
[03:55.946] RECV (ch=0) detach(handle:0,closed:True)
[03:55.949] SEND (ch=0) end()
[03:56.533] RECV (ch=0) end()
[03:56.536] SEND (ch=0) close()
[03:56.583] RECV (ch=0) close()
[03:33.979] SEND AMQP 3 1 0 0
[03:33.994] SEND sasl-init(mechanism:PLAIN,initial-response:006F776E657200657079677642637A49674C546F7554772B756850327733457369334E47356857704D694F565045703058383D,hostname:amqpnetlitetest.servicebus.windows.net)
[03:34.025] RECV AMQP 3 1 0 0
[03:34.072] RECV sasl-mechanisms(sasl-server-mechanisms:[PLAIN,EXTERNAL])
[03:34.337] RECV sasl-outcome(code:0,additional-data:57656C636F6D6521)
[03:34.337] SEND AMQP 0 1.0.0
[03:34.337] SEND (ch=0) open(container-id:51fe1ee5-0831-4e12-b069-d541aa20d7ef,host-name:amqpnetlitetest.servicebus.windows.net,max-frame-size:16384,channel-max:3)
[03:34.337] SEND (ch=0) begin(next-outgoing-id:4294967293,incoming-window:2048,outgoing-window:2048,handle-max:7)
[03:34.353] SEND (ch=0) attach(name:send-linkq1,handle:0,role:False,source:source(),target:target(address:q1),initial-delivery-count:0)
[03:35.242] RECV AMQP 0 1 0 0
[03:35.258] RECV (ch=0) open(container-id:9c6441b430b5446eb44519f43f3ef490_G8,max-frame-size:16384,channel-max:3,idle-time-out:240000)
[03:35.258] RECV (ch=0) begin(remote-channel:0,next-outgoing-id:1,incoming-window:2048,outgoing-window:2048,handle-max:7)
[03:35.258] RECV (ch=0) attach(name:send-linkq1,handle:0,role:True,source:source(),target:target(address:q1),max-message-size:262144)
[03:35.273] RECV (ch=0) flow(next-in-id:4294967293,in-window:2048,next-out-id:1,out-window:2048,handle:0,delivery-count:0,link-credit:50,available:0,echo:False)
[03:35.289] SEND (ch=0) transfer(handle:0,delivery-id:0,delivery-tag:00000000,message-format:0,settled:True,batchable:True)
[03:40.250] SEND (ch=0) attach(name:receive-linkq1,handle:1,role:True,source:source(address:q1),target:target())
[03:40.250] SEND (ch=0) flow(next-in-id:0,in-window:2048,next-out-id:4294967293,out-window:2047,handle:1,delivery-count:0,link-credit:5)
[03:41.014] RECV (ch=0) attach(name:receive-linkq1,handle:1,role:False,rcv-settle-mode:1,source:source(address:q1),target:target(),initial-delivery-count:0,max-message-size:18446744073709551615)
Qpid broker
03:46.273] SEND (ch=0) open(container-id:8bb44ccb-a3a2-473f-8f4b-1b4496466f50,host-name:192.168.10.19,max-frame-size:16384,channel-max:3)
[03:46.273] SEND (ch=0) begin(next-outgoing-id:4294967293,incoming-window:2048,outgoing-window:2048,handle-max:7)
[03:46.273] RECV AMQP 0 1 0 0
[03:46.289] SEND (ch=0) attach(name:send-linkq1,handle:0,role:False,source:source(),target:target(address:q1),initial-delivery-count:0)
[03:47.365] RECV (ch=0) open(container-id:cf2bbc72-0962-48a0-bebe-83cc9b4ec181,max-frame-size:32768,channel-max:3,properties:[qpid.instance_name:Broker,product:qpid,version:0.26,qpid.build:1563358])
[03:47.365] RECV (ch=0) begin(remote-channel:0,next-outgoing-id:0,incoming-window:2048,outgoing-window:2048)
[03:47.365] RECV (ch=0) attach(name:send-linkq1,handle:0,role:True,source:source(),target:target(address:q1))
[03:47.365] RECV (ch=0) flow(next-in-id:4294967293,in-window:2048,next-out-id:0,out-window:2048,handle:0,delivery-count:0,link-credit:100,echo:False)
[03:47.365] SEND (ch=0) transfer(handle:0,delivery-id:0,delivery-tag:00000000,message-format:0,settled:True,batchable:True)
[03:52.357] SEND (ch=0) attach(name:receive-linkq1,handle:1,role:True,source:source(address:q1),target:target())
[03:52.357] SEND (ch=0) flow(next-in-id:0,in-window:2048,next-out-id:4294967293,out-window:2047,handle:1,delivery-count:0,link-credit:5)
[03:53.418] RECV (ch=0) attach(name:receive-linkq1,handle:1,role:False,source:source(address:q1),target:target(),initial-delivery-count:0)
[03:53.418] RECV (ch=0) transfer(handle:1,delivery-id:0,delivery-tag:0000000000000000,message-format:0)
[03:54.104] RECV (ch=0) disposition(role:False,first:0,last:0,settled:True,state:accepted())
[03:54.104] RECV (ch=0) flow(next-in-id:4294967294,in-window:2048,next-out-id:1,out-window:2048,handle:1,delivery-count:1,link-credit:4,available:0,echo:False)
[03:54.104] SEND (ch=0) disposition(role:True,first:0,settled:True,state:accepted())
[03:54.120] SEND (ch=0) detach(handle:0,closed:True)
[03:54.120] RECV (ch=0) detach(handle:0,closed:True)
[03:54.120] SEND (ch=0) end()
[03:54.120] RECV (ch=0) detach(handle:1)
[03:54.120] SEND (ch=0) detach(handle:1,closed:True)
[03:54.120] RECV (ch=0) end()
[03:54.120] SEND (ch=0) close()
[03:54.120] RECV (ch=0) close(error:error(condition:amqp:connection:framing-error,description:Frame received on channel 0 which is not known as a begun session.))
SEND AMQP 3 1 0 0
[03:14.661] SEND sasl-init(mechanism:PLAIN,initial-response:0061646D696E0061646D696E,hostname:192.168.10.19)
[03:14.661] RECV AMQP 3 1 0 0
[03:14.661] RECV sasl-mechanisms(sasl-server-mechanisms:[AMQPLAIN,PLAIN,CRAM-MD5])
[03:14.676] RECV sasl-outcome(code:0)
[03:14.676] SEND AMQP 0 1.0.0
[03:14.676] SEND (ch=0) open(container-id:b3c9c1d4-4ae8-459f-bed9-8ace7d0375ee,host-name:192.168.10.19,max-frame-size:16384,channel-max:3)
[03:14.676] SEND (ch=0) begin(next-outgoing-id:4294967293,incoming-window:2048,outgoing-window:2048,handle-max:7)
[03:14.676] RECV AMQP 0 1 0 0
[03:14.676] SEND (ch=0) attach(name:send-linkq1,handle:0,role:False,source:source(),target:target(address:q1),initial-delivery-count:0)
[03:15.768] RECV (ch=0) open(container-id:cf2bbc72-0962-48a0-bebe-83cc9b4ec181,max-frame-size:32768,channel-max:3,properties:[qpid.instance_name:Broker,product:qpid,version:0.26,qpid.build:1563358])
[03:15.768] RECV (ch=0) begin(remote-channel:0,next-outgoing-id:0,incoming-window:2048,outgoing-window:2048)
[03:15.768] RECV (ch=0) attach(name:send-linkq1,handle:0,role:True,source:source(),target:target(address:q1))
[03:15.768] RECV (ch=0) flow(next-in-id:4294967293,in-window:2048,next-out-id:0,out-window:2048,handle:0,delivery-count:0,link-credit:100,echo:False)
[03:15.784] SEND (ch=0) transfer(handle:0,delivery-id:0,delivery-tag:00000000,message-format:0,settled:True,batchable:True)
[03:20.776] SEND (ch=0) attach(name:receive-linkq1,handle:1,role:True,source:source(address:q1),target:target())
[03:20.776] RECV (ch=0) attach(name:receive-linkq1,handle:1,role:False,source:source(address:q1),target:target(),initial-delivery-count:0)
[03:20.776] SEND (ch=0) flow(next-in-id:0,in-window:2048,next-out-id:4294967293,out-window:2047,handle:1,delivery-count:0,link-credit:5)
[03:20.776] RECV (ch=0) transfer(handle:1,delivery-id:0,delivery-tag:0000000000000000,message-format:0)
[03:28.311] SEND (ch=0) disposition(role:True,first:0,settled:True,state:accepted())
[03:28.311] SEND (ch=0) detach(handle:0,closed:True)
[03:28.311] RECV (ch=0) disposition(role:False,first:0,last:0,settled:True,state:accepted())
[03:28.311] RECV (ch=0) flow(next-in-id:4294967294,in-window:2048,next-out-id:1,out-window:2048,handle:1,delivery-count:1,link-credit:4,available:0,echo:False)
[03:28.311] RECV (ch=0) detach(handle:0,closed:True)
[03:28.326] SEND (ch=0) end()
[03:28.326] RECV (ch=0) detach(handle:1)
[03:28.326] SEND (ch=0) detach(handle:1,closed:True)
[03:28.326] RECV (ch=0) end()
[03:28.326] SEND (ch=0) close()
[03:28.326] RECV (ch=0) close(error:error(condition:amqp:connection:framing-error,description:Frame received on channel 0 which is not known as a begun session.))
ActiveMQ
[03:27.322] RECV sasl-outcome(code:0)
[03:27.322] SEND AMQP 0 1.0.0
[03:27.337] SEND (ch=0) open(container-id:9ecb0e5d-7493-46e9-8084-028b95de004b,host-name:192.168.10.19,max-frame-size:16384,channel-max:3)
[03:27.337] SEND (ch=0) begin(next-outgoing-id:4294967293,incoming-window:2048,outgoing-window:2048,handle-max:7)
[03:27.337] RECV AMQP 0 1 0 0
[03:27.337] RECV (ch=0) open(container-id:,host-name:,max-frame-size:1048576)
[03:27.337] SEND (ch=0) attach(name:send-linkq1,handle:0,role:False,source:source(),target:target(address:q1),initial-delivery-count:0)
[03:27.337] RECV (ch=0) begin(remote-channel:0,next-outgoing-id:1,incoming-window:0,outgoing-window:0,handle-max:1024)
[03:27.337] RECV (ch=0) attach(name:send-linkq1,handle:0,role:True,snd-settle-mode:2,rcv-settle-mode:0,source:source(),target:target(address:q1))
[03:28.320] RECV (ch=0) flow(next-in-id:4294967293,in-window:2047,next-out-id:1,out-window:0,handle:0,delivery-count:0,link-credit:100)
[03:28.336] SEND (ch=0) transfer(handle:0,delivery-id:0,delivery-tag:00000000,message-format:0,settled:True,batchable:True)
[03:33.328] SEND (ch=0) attach(name:receive-linkq1,handle:1,role:True,source:source(address:q1),target:target())
[03:33.328] SEND (ch=0) flow(next-in-id:0,in-window:2048,next-out-id:4294967293,out-window:2046,handle:1,delivery-count:0,link-credit:5)
[03:33.967] RECV (ch=0) attach(name:receive-linkq1,handle:1,role:False,snd-settle-mode:2,rcv-settle-mode:0,source:source(address:q1),target:target(),incomplete-unsettled:False,initial-delivery-count:0)
[03:33.967] RECV (ch=0) transfer(handle:1,delivery-id:0,delivery-tag:30,message-format:0)
[03:35.075] SEND (ch=0) disposition(role:True,first:0,settled:True,state:accepted())
[03:35.075] SEND (ch=0) detach(handle:0,closed:True)
[03:35.278] RECV (ch=0) detach(handle:0,closed:True)
[03:35.278] SEND (ch=0) end()
[03:35.278] RECV (ch=0) end()
[03:35.278] SEND (ch=0) close()
[03:35.278] RECV (ch=0) close()
[03:51.704] SEND sasl-init(mechanism:PLAIN,initial-response:0061646D696E0061646D696E,hostname:192.168.10.19)
[03:51.704] RECV AMQP 3 1 0 0
[03:51.720] RECV sasl-mechanisms(sasl-server-mechanisms:[ANONYMOUS,PLAIN])
[03:51.720] RECV sasl-outcome(code:0)
[03:51.720] SEND AMQP 0 1.0.0
[03:51.720] SEND (ch=0) open(container-id:eeb85536-2f52-47ca-af51-7925045f6a47,host-name:192.168.10.19,max-frame-size:16384,channel-max:3)
[03:51.720] SEND (ch=0) begin(next-outgoing-id:4294967293,incoming-window:2048,outgoing-window:2048,handle-max:7)
[03:51.720] RECV AMQP 0 1 0 0
[03:51.736] RECV (ch=0) open(container-id:,host-name:,max-frame-size:1048576)
[03:51.736] SEND (ch=0) attach(name:send-linkq1,handle:0,role:False,source:source(),target:target(address:q1),initial-delivery-count:0)
[03:51.736] RECV (ch=0) begin(remote-channel:0,next-outgoing-id:1,incoming-window:0,outgoing-window:0,handle-max:1024)
[03:51.736] RECV (ch=0) attach(name:send-linkq1,handle:0,role:True,snd-settle-mode:2,rcv-settle-mode:0,source:source(),target:target(address:q1))
[03:52.750] RECV (ch=0) flow(next-in-id:4294967293,in-window:2047,next-out-id:1,out-window:0,handle:0,delivery-count:0,link-credit:100)
[03:52.765] SEND (ch=0) transfer(handle:0,delivery-id:0,delivery-tag:00000000,message-format:0,settled:True,batchable:True)
[03:57.757] SEND (ch=0) attach(name:receive-linkq1,handle:1,role:True,source:source(address:q1),target:target())
[03:57.757] SEND (ch=0) flow(next-in-id:0,in-window:2048,next-out-id:4294967293,out-window:2046,handle:1,delivery-count:0,link-credit:5)
[03:58.366] RECV (ch=0) attach(name:receive-linkq1,handle:1,role:False,snd-settle-mode:2,rcv-settle-mode:0,source:source(address:q1),target:target(),incomplete-unsettled:False,initial-delivery-count:0)
[03:58.381] RECV (ch=0) transfer(handle:1,delivery-id:0,delivery-tag:30,message-format:0)
[03:59.302] SEND (ch=0) disposition(role:True,first:0,settled:True,state:accepted())
[03:59.302] SEND (ch=0) detach(handle:0,closed:True)
[03:59.504] RECV (ch=0) detach(handle:0,closed:True)
[03:59.504] SEND (ch=0) end()
[03:59.504] RECV (ch=0) end()
[03:59.504] SEND (ch=0) close()
[03:59.504] RECV (ch=0) close()
Thanks,
Paolo.
Paolo Patierno