Skip to content

Instantly share code, notes, and snippets.

@mclasson

mclasson/gist:5993927

Last active Dec 19, 2015
Embed
What would you like to do?
How to receive message from Microsoft Azure Service Bus Queue
while (true)
{
BrokeredMessage message = Client.Receive();
if (message != null)
{
try
{
var msgStream = message.GetBody<Stream>();
StreamReader sr = new StreamReader(msgStream);
var order = new System.Web.Script.Serialization.JavaScriptSerializer()
.Deserialize<Order>(sr.ReadToEnd());
if (order != null)
{
order.CreatedOn = message.EnqueuedTimeUtc;
//Act on order
}
message.Complete();
}
catch
{
message.DeadLetter();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.