So we've been looking into the Azure Service Bus recently and we're a bit confused as to whether we should use an infinite loop to poll the queue/subscription or whether we should use the OnMessage callback/message pump functionality. What is going to execute fewer operations and thus cost less?
Ideally we want an event-driven system so we aren't wasting operations and it's just generally a much nicer approach.
My question is, is using OnMessage which is defined as "Processes a message in an event-driven message pump" really event-driven?
If you take a look at this page (QueueClient.OnMessage): https://msdn.microsoft.com/library/azure/microsoft.servicebus.messaging.queueclient.onmessage.aspx you'll notice the remark at the bottom which states that it is basically a wrapper around an infinite loop which is calling the Receive() method. That doesn't sound very event-driven to me.
Now if you look at this page (SubscriptionClient.OnMessage): https://msdn.microsoft.com/en-us/library/azure/dn130336.aspx, that remark is not present. So is it the same for topics/subscriptions and queues or is it actually event-driven for subscriptions but not for queues?
Why are they even saying it's event-driven when it's clearly not? The fact that the remark on the QueueClient.OnMessage page has the words "infinite loop" and "every receive operation is a billable event" is somewhat scary.
Also, I'm not really concerned about how much/little it will cost either way, I'm more interested in making it as efficient as possible.
In Event Hubs, the messages received from various event producers will be stored in a single stream from where the receivers can look but cannot remove it. Whereas, in Service Bus, the receivers can get their own copy of the message which means that it works based on the receive/delete model for collecting message.
Azure Event Hubs is a big data streaming platform and event ingestion service. It can receive and process millions of events per second. It facilitates the capture, retention, and replay of telemetry and event stream data.
The Azure Service Bus cloud service uses the AMQP 1.0 as its primary means of communication.
Microsoft Azure Service Bus is a Cloud-based Messaging as a Service (MaaS) Platform. It is a high-performance, real-time, and fault-tolerant service that transfers messages between your applications and databases securely.
I've not used OnMessage, but the question interested me so I did some digging.
My understanding is that the OnMessage approach just encapsulates away some of the usual concerns to do with processing messages from a queue to give you a cleaner/easier way to do it with a lot less to be concerned about. So instead of writing all the scaffolding around polling, you can focus more on a "push-like/event driven" implementation (message pump model).
And so you are correct in that it is basically still just a loop calling Receive() - so with the default timeouts, the number of polls would be the same and therefore same cost.
I came across these references:
http://fabriccontroller.net/introducing-the-event-driven-message-programming-model-for-the-windows-azure-service-bus/
http://www.flyersoft.net/?p=971 - check the comments too, as this covers the same question as yours.
So is it the same for topics/subscriptions and queues or is it actually event-driven for subscriptions but not for queues?
I am not 100%, but my assumption based on my research is that it is the same and it's just a case that the documentation is not clear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With