locked
Is it able to send Azure service bus message in a Windows Service RRS feed

  • Question

  • Is it able to send Azure service bus message in a Windows Service?

    Recently, I build a Windows NT Service to send message to Azure queue. But it failed. I created two test console application, one uses the same code as my Windows NT Service to send Service Bus message, another one to receive the message. The test console applications successfully send and receive messages. In my windows NT service, it dosen't throw any messages or errors.

    What I want to know is that whether Azure Service Bus Message is supported in Windows NT Service.

    My application is neither a worker role nor a web role. It is just a Windows NT service.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us

    Monday, May 14, 2012 9:54 AM

Answers

  • Hi,

    How many concurrent requests will the service send? I seem cannot think of any reasons of this symptom other than this. (When you use async call you're possible to have more concurrent requests than sync one)

    If you're only testing one request, do you get any exceptions or error messages when it fails?


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.





    Friday, May 18, 2012 9:12 AM
  • Hi,

    >If using QueueClient.BegindSend method in async mode, it will just "begin" to send, when current thread is idle, it will send the message. So when I am debugging, current thread will keeps running in debugger, so the message will not be sent.

    A thread will not occupy all the CPU time if there are other threads in the same process. At this moment I'm not quite sure why the Thread.Sleep gets your application work. My guess is you're not adding a infinite loop after calling the async method so that the main thread finishs processing, is stopped and then the background threads are stopped:

    http://stackoverflow.com/questions/1158733/async-call-for-wcf-service-hosted-in-windows-service

    http://msdn.microsoft.com/en-us/library/h339syd0.aspx

    (But it doesn't explain why the testing Console app works. Maybe the code is different. e.g. the main thread is not stopped as you added a Console.ReadLine at the end or something similar?)

    If it's incorrect please post your code of the Windows Service and the code of the testing Console application. It is helpful to explain the behavior with the code.


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.







    Monday, May 21, 2012 7:25 AM

All replies

  • Maybe the messege from service is sent correctly, but your firewall or some other app can catch it and deny its way to Service Bus. Try to investigate this ;-)

    I think there is no reason for NT Service cant talk to Service Bus


    Microsoft Platform Developer Cloudikka blog

    Monday, May 14, 2012 11:47 AM
  • Could it be a permissions issue with the service?  Perhaps the service is running as a user account that doesn't allow it to access the network.

    And there is no exception from the code in the Windows Service?

    Monday, May 14, 2012 12:22 PM
  • Thanks for your reply. Actually, I found that if I use QueueClient.BeginSend method to begin an asynchronous operation to send a message, it failed. If I just use QueueClient.Send method, it successfully to send messages.

    It is strange that I can send message using BeginSend in a test console application.

    I have not found root cause, but at least it works now.

    Thank you again. Have a nice day.

    Wednesday, May 16, 2012 1:19 AM
  • If anyone knows the root cause for this issue, it is appreciated.
    Wednesday, May 16, 2012 1:21 AM
  • Hi,

    How many concurrent requests will the service send? I seem cannot think of any reasons of this symptom other than this. (When you use async call you're possible to have more concurrent requests than sync one)

    If you're only testing one request, do you get any exceptions or error messages when it fails?


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.





    Friday, May 18, 2012 9:12 AM
  • Hi Allen,

    I did debug the issue from Visual Studio. I found that if I add Thread.Sleep() to keep it running, the message will be sent successfully. So I think the root cause may be different operation modes of async  and sync sending message. if using QueueClient.Send method in sync mode, it will send the message immediately so that I can receive message. If using QueueClient.BegindSend method in async mode, it will just "begin" to send, when current thread is idle, it will send the message. So when I am debugging, current thread will keeps running in debugger, so the message will not be sent.

    If any wrong understanding, please let me know.

    Friday, May 18, 2012 9:35 AM
  • Hi,

    >If using QueueClient.BegindSend method in async mode, it will just "begin" to send, when current thread is idle, it will send the message. So when I am debugging, current thread will keeps running in debugger, so the message will not be sent.

    A thread will not occupy all the CPU time if there are other threads in the same process. At this moment I'm not quite sure why the Thread.Sleep gets your application work. My guess is you're not adding a infinite loop after calling the async method so that the main thread finishs processing, is stopped and then the background threads are stopped:

    http://stackoverflow.com/questions/1158733/async-call-for-wcf-service-hosted-in-windows-service

    http://msdn.microsoft.com/en-us/library/h339syd0.aspx

    (But it doesn't explain why the testing Console app works. Maybe the code is different. e.g. the main thread is not stopped as you added a Console.ReadLine at the end or something similar?)

    If it's incorrect please post your code of the Windows Service and the code of the testing Console application. It is helpful to explain the behavior with the code.


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.







    Monday, May 21, 2012 7:25 AM