How to receive message from Azure Service Bus Queue without polling a queue
-
sábado, 25 de fevereiro de 2012 23:24
Hi,
Looking for samples on how to subscribe to a service bus queue so that whenever a new message is added to the queue it calls a callback method and doesn't need to keep polling the queue in infinite loop.-Sachin Sancheti
Todas as Respostas
-
domingo, 26 de fevereiro de 2012 00:31
The Service Bus .NET API is full duplex. It's "pull", but not "poll".
We register your wish to receive a message on the broker and service that request once we have a message. If that happens 30 minutes after you called BeginReceive, that message comes down the socket 30 minutes later. In the meantime we maintain that socket with periodic pings that keep it from timing out given that the Windows Azure load balancer (and other infrastructures) impose a 60s idle timeout. So we're not polling with the binary protocol used by the .NET client.
If you call Receive/BeginReceive() with a timeout > 60s we're doing all that for you under the hood.
What you really may be asking for is a push programming model. You can get that out-of-the-box with WCF and the NetMessagingBinding. There you just write a service and have messages be dispatched on that service and WCF does the receiving for you.
That said, receiving messages explicitly in a loop has a significant number of advantages including load leveling and load balancing.
I would strongly recommend that you take an hour to watch this talk: http://channel9.msdn.com/posts/ServiceBusTopicsAndQueues
Best regards
Clemens- Sugerido como Resposta Navarajan A quarta-feira, 14 de março de 2012 11:15
-
domingo, 26 de fevereiro de 2012 01:10
Thanks Clemens.
What a coincidenc!! I asked that question after watching your Build videos, awesome videos.Right, i am looking for push programming model,since a receive against an empty queue is considered a billable message. Yes, I agree for load leveling a loop is required.
It would be great if you could point to the samples which implements push programming model with Azure AppFabric Service Bus Queue.
Also are the code samples which you used in videos available somewhere?
Thanks a ton, Service Bus is Super Cool. :)
-Sachin Sancheti
-
domingo, 26 de fevereiro de 2012 02:49
We only charge for payload messages, Sachin. The WCF programming model does exactly the same thing; it maintains a loop.
http://msdn.microsoft.com/en-us/library/windowsazure/hh532034%28v=vs.103%29.aspx
Hope that helps
Clemens- Marcado como Resposta Sachin Sancheti domingo, 26 de fevereiro de 2012 05:21
-
quinta-feira, 13 de dezembro de 2012 14:52Hi Clemens - when you say you only charge for payload messages, are you saying that a while loop which invokes the QueueClient BegingReceive/EndReceive methods should not create a charge on the account? I used this for the first time yesterday (3 month trial) and very quickly spent more than the free 500,000 messages. Just leaving my test worker project running, another 1 million messages were charged for. This suggests that a receive only ends up as a payload/chargeable message?

