0

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
  • 193
  • 2
  • 12

1 Answers1

1

The Service Bus client code works the same anywhere else, including Windows Services.

But!

NT Services often run as Local Service or Network Service on your machine and depending on your network setup, that account may not have sufficient rights to talkthroiugh intermediareies like proxies. We know that at several of our clients, IT doesn't allow machine accounts through the external proxies and therefore the machine account won't work. That said, you should and will see exceptions being thrown if communication does not work, so you should double-check your code for that and/or also turn on WCF tracing.

Clemens

Clemens Vasters
  • 2,666
  • 16
  • 28
  • 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. I have not found root cause, but at least it works now. – Paul Zhou May 16 '12 at 01:17
  • That's odd, because under the covers that's the exact same code path. Did you call EndSend? – Clemens Vasters May 16 '12 at 01:25
  • Yes, I can share my code snippet:`public void BeginSendMessage(T messageBody) { BrokeredMessage message = new BrokeredMessage("Test Message"); message.Properties["testproperty"] = "test value"; queueClient.BeginSend(message, new AsyncCallback(SendCompleted), queueClient); } private void SendCompleted(IAsyncResult result) { QueueClient queueClient = result.AsyncState as QueueClient; queueClient.EndSend(result); }` – Paul Zhou May 16 '12 at 06:54