Pull messages from Azure service Bus queue in windows service

ramu boyapati 1 Reputation point
2021-01-18T21:42:52.843+00:00

Hello,

I have a requirement where I need to pull messages from the Azure service bus and store it in the On-prem Database for further processing. I am in the process of writing a windows service that has an infinite loop with a cancellation token as below. I have a few questions about this scanrio.

1) How does pull timeout works? Does it throw any exceptions?
2) How does MS calculates the cost for this long polling?
3) How do I determine how long the Thread should be sleeping?
Please see below the code, It basically an MS sample wrapped in an infinite loop for pulling messages from Azure Service Bus Queue.

It's not letting me post the code

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
560 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 69,756 Reputation points
    2021-01-22T07:58:32.363+00:00

    Hi @ramu boyapati

    Can you please confirm if you want to use the Azure service REST API or service bus SDK's?

    If it is service bus SDK then you can refer to receiving message from a queue section. When using AMQP, which is the default protocol, messages are acquired over a stateful protocol and with a credit-based flow. "Long polling" implies that there is a request and the response is being waited for an extended period of time, and that's never the case in AMQP. You can also refer to Flow Control in the AMQP spec. As in the example, the application will keep on waiting for the messages and you can customize it according to your business needs.