3
votes

I have a question about the azure service bus billing. If I have the following code, and a message isn't sent for a long time say 5 hours.

Assume I only have one subscription and the code is as below. In this scenario over that 5 hour period what do I get charged (is it once for sending and once for downloading, or do I incur charges for the polling keep alive that azure implements in the background)?

enter code here
   var subscriptionClient = SubscriptionClient.CreateFromConnectionString(ConnString, topic, subscriptionName);
            while (true)
            {

                var message = subscriptionClient.Receive();
                if (message != null)
                {
                    try
                    {
                        message.Complete();


                    }
                    catch (Exception)
                    {
                        // Indicate a problem, unlock message in subscription
                        message.Abandon();
                    }
                }
                else 
                {
                    Console.WriteLine("null message received");
                }
                Thread.Sleep(25);
            }
2

2 Answers

1
votes

From the code above you will get charged for a single message every time the Receive call returns (even if the result is null). The default timeout for the Receive call is 60 seconds so in the case there is no message for 5 hours, your code will return every one minute and then sleep for 25 seconds so assume that per hour you will get charged for 48 messages (1 min timeout and 25 second wait). You can call the overload of Receive that takes a timeout and pass in 5 hour timeout there. Here the connection will be kept alive for 5 hours before it returns and thus no charges will occur during that time.

From a back of the envelope calculation: A single receiver, running with one minute timeout with no wait and no real messages will get a message charged every minute. That is less than 5cents for the entire month. See billing calculator here

1
votes

Only Message Transaction will be counted( Send,Receive)... Azure not charging for KeepAlive Messages...

Refer MSDN topic: http://msdn.microsoft.com/en-us/library/hh667438.aspx#BKMK_SBv2FAQ2_1