Written by Altınok Darıcı on 13 - Feb - 2015

Sending Message from Windows Phone 8.1 to Azure Service Bus

Sending and receiving message to Azure Service Bus queue is a bit different in Windows Phone 8.1, because Service Bus NuGet package is not compatible. But we can use WindowsAzure.Messaging.Managed NuGet Package to connect it.

1. Install NuGet Package
Install-Package WindowsAzure.Messaging.Managed

2. Create Queue
Microsoft.WindowsAzure.Messaging.Queue.CreateAsync("path","connectionstring");
//you can delete it, Microsoft.WindowsAzure.Messaging.Queue.DeleteAsync("path","connectionstring");

3. Create Queue Client
Microsoft.WindowsAzure.Messaging.Queue queueClient = newMicrosoft.WindowsAzure.Messaging.Queue("QueuePath""Endpoint=sb://[namespace].servicebus.windows.net; SharedSecretIssuer=owner;SharedSecretValue=someSecret");

4. Send Message To Queue
await queueClient.SendAsync(new Microsoft.WindowsAzure.Messaging.Message("test message"));

5. Receive Message From Queue
var result = await queueClient.ReceiveAsync<string>();

6. OnMessage 
queueClient.OnMessage((message)=>{
          //process message;
});


Also, you can use WindowsAzure.Messaging.Managed NuGet package for Topic & Subscription  & Notification Hub
 
comments powered by Disqus