Partager via


How to integrate a WCF Workflow Service with Service Bus Queues and Topics

Introduction

This document provides an introduction to Service Bus Brokered Messaging and a prescriptive guidance on how to integrate a WCF workflow service with Service Bus Queues and Topics. The document will walk you through how to build a WCF workflow service that uses Queues and Topics to exchange messages with a client application.

Description

The following figure shows the high-level architecture of the demo:

  

Message Flow:

  1. A client application uses a WCF proxy and the NetMessagingBinding to send a request message to the requestqueue or to the requesttopic.
  2. The WCF workflow service running in a console application or IIS receives the request message from the requestqueue or the ItalyMilan subscription defined on the requesttopic.

 

  1. The WCF workflow service, shown in the figure above,  performs the following actions:
  • The custom BrokeredMessagePropertyActivity (identified by the Get BrokeredMessage display name) reads the BrokeredMessageProperty from the inbound message and assigns its value to a workflow variable defined in the outermost the Sequential activity.
  • The Receive activity retrieves the message from the requestqueue or the ItalyMilan subscription of the requesttopic.
  • The custom CalculatorActivity receives the inbound message and BrokeredMessageProperty as input arguments, processes the request message and generates a response message and an outbound BrokeredMessageProperty.  When running in a console application, the activity traces the properties of the inbound and outbound BrokeredMessageProperty in the standard output.
  • The If activity reads the address contained in the ReplyTo property of the inbound BrokeredMessageProperty.
    • If the string contains the word “topic”, the response is sent to the responsetopic.
    • Otherwise, the response is sent to the responsequeue.
    • In both cases, an instance of the BrokeredMessagePropertyActivity (identified by the Set BrokeredMessage display name) is used to wrap the Send activity and assign the outbound BrokeredMessageProperty to the properties collection of the WCF response message.
  • The WCF workflow service writes the reply message to the responsequeue or responsetopic.
  • The client application uses a WCF service with two distinct endpoints to retrieve the reply message from the responsequeue or from the responsetopic. In an environment with multiple client applications, each of them should use a separate queue or subscription to receive response messages from BizTalk. 

The solution contains a Windows Azure project called ServiceBusAndWFSample and a web role project called WorkflowServices that you can use to run the WCF workflow service in Full IIS mode in a web role as shown in the following figure. You can eventually use the WorkflowServices project to run the WCF workflow service on-premises, in IIS and Windows Server AppFabric 1.1.

 

Article

You can read the related article on MSDN at https://msdn.microsoft.com/en-us/library/hh709041(v=VS.103).aspx. The code can be found on MSDN Code Gallery at https://code.msdn.microsoft.com/How-to-integrate-a-WCF-43b08deb.