Book Image

SOA Patterns with BizTalk Server 2013 and Microsoft Azure

By : Richard Seroter, Mark T Brimble, Coen J Dijkgraaf, Mahindra Morar, Mark Brimble, Colin Dijkgraaf, Johann Cooper
Book Image

SOA Patterns with BizTalk Server 2013 and Microsoft Azure

By: Richard Seroter, Mark T Brimble, Coen J Dijkgraaf, Mahindra Morar, Mark Brimble, Colin Dijkgraaf, Johann Cooper

Overview of this book

Table of Contents (21 chapters)
SOA Patterns with BizTalk Server 2013 and Microsoft Azure Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Subscriptions


To receive messages from a Topic Queue, you would create a Subscription. A Subscription resembles a virtual Queue that receives a copy of the message sent to a topic queue.

Note

Note that a single subscription cannot be used for multiple topics. Instead, you need to create multiple subscriptions.

Typically the following code would be duplicated for each interested consumer, specifying the Topic and Subscription names in the constructor:

MessagingFactory factory = MessagingFactory.Create(uri, token);

//create a consumer for the subscription 
SubscriptionClient subscriber1 = factory.CreateSubscriptionClient(topicName, 
SubscriptionName,ReceiveMode.PeekLock);

Just like with normal queues, you can use either ReceiveAndDelete or PeekLock (receive modes) to read the message of the virtual Queue.

Once the client has created the Subscription, the messages can be read off the virtual queue as follows:

while ((receivedMessage = subscriber1.Receive(TimeSpan.FromSeconds(5))) != null)
{
try
...