Muhammad Faizan
Muhammad Faizan

Reputation: 913

How a message is send to receiver from queue/subscription?

My question is that how a receiver in service bus listens for new message? Does it send a query request to service bus for any new message after some interval or the service bus pushes any new message to the connected receivers?

I am using .NET client library and it uses SBMP protocol by default.

Upvotes: 0

Views: 320

Answers (2)

Sean Feldman
Sean Feldman

Reputation: 26057

When you do manual receive (or batch receive), it doesn't really matter since the server will give you whatever your requested (or what it has at that moment if it's less than what was requested). In case you're using the OnMessage API with a callback, regardless of the transport, you'll get callback invocation upon each message irregardless was it pushed or pulled. With SBMP messages are polled from the broker by the client. With AMQP they are pushed on the client by the broker.

Upvotes: 1

lostintranslation
lostintranslation

Reputation: 533

My answer refers to the Azure Service Bus SDK which runs over AMQP (Link -> https://github.com/Azure/azure-service-bus-java ).

The MessageReceiver object is used to receive messages from a queue whenever you need one.

This class has a receive function which takes in a server wait time as parameter (Default is 30 seconds ).

This means that if there are no messages in the queue , it will not return immediately , but will wait for 30 seconds or whatever time you specified for new messages.

If there is a new message earlier , then it will return at that point.

This is basically called long polling.

It saves the client from continuously polling the queue.

Upvotes: 1

Related Questions