Wednesday, January 20, 2010

Use .NET Built-in Methods to Save Time and Headaches


During our everyday programming tasks we run into several repetitive code blocks that after the 20th time you implement them become really annoying. In this post Shay Friedman will take you through several of such blocks and show you how to implement them using built-in .NET methods.


Tuesday, January 12, 2010

Implementing Design Patterns in BizTalk Orchestrations

The following entries briefly describe each pattern and point to the topics or samples that show how to implement the patterns using BizTalk Orchestration Designer.


Aggregator

Aggregator is the pattern of receiving information from multiple sources and consolidating it into a single message. For an example of this pattern, see Aggregate.odx in Aggregator (BizTalk Server Sample).


Calling Pipelines from an Orchestration

You can call send and receive pipelines from your orchestrations. This allows the reuse of pipelines and helps maintain the decoupling of an orchestration from the pipeline stages. For an example of this pattern, see Aggregate.odx in Aggregator (BizTalk Server Sample). Another example is CMP.odx in Composed Message Processor (BizTalk Server Sample). See also How to Use Expressions to Execute Pipelines.


Composed Message Processor

Composed Message Processor is the pattern of processing individual items from an aggregated or batched interchange message. For an example of this pattern, see CMP.odx in Composed Message Processor (BizTalk Server Sample).


Content-Based Router

Content-Based Router is the pattern of determining the recipient of a message based on some part of the message content. For an example of this pattern, see CBRSample (BizTalk Server Sample).


Dynamic Router

Dynamic Router is the pattern of determining the destination address as well as the transport protocol based on the result of message processing. You can use a dynamic send port or a Role Link shape to implement this pattern. For an example of this pattern, see ReceiveSend.odx in SendMail. Another example is SupplierProcess.odx in PartyResolution (BizTalk Server Sample).


Error Handling

BizTalk Server allows you to designate automated handling of messaging failures as an alternative to the default behavior of placing failed messages in the Suspended queue. You can route failed messages to a subscribing port for reporting or processing. For an example of this pattern, see ResubmitLogic.odx in Error Handling (BizTalk Server Samples Folder).


Exception Handling and Compensation

You can use an exception handler and a Throw Exception shape or an Expression shape for exception handling. For example, you can place the following code in the Expression shape to throw the exception:-

excp = new System.Exception();
throw(excp);  

You can use a compensation block and a Compensate shape to perform the compensation on the transactions that have been committed. For an example of this pattern, see UpdateContact.odx in Compensation (BizTalk Server Sample). Another example is inCustom Exceptions.


Message Broker

Message Broker is the pattern of determining the destination of a message and still maintaining control over the message flow. For an example of this pattern, see OrderBroker.odx in File Inventory for the Business Process Management Solution.


Message Filter

The Message Filter pattern selects messages meeting particular criteria for processing. You can implement this pattern by adding the filter expression to an activated Receive shape. For more information, see Using Filters With the Receive Message Shape.


Message Translator

The Message Translator pattern converts a message from one form to another form. You can implement this pattern by using a BizTalk map with a Transform shape in an orchestration. For an example of this pattern, see HelloOrchestration.odx in HelloWorld (BizTalk Server Sample).


Parallel Convoy

The Parallel Convoy pattern enables multiple single items to join together to achieve something that an individual item cannot accomplish by itself. The set of related items can arrive in any order, but BizTalk Server must receive all of them before starting the process. For an example of this pattern, see http://go.microsoft.com/fwlink/?LinkId=56035.


Scatter and Gather

The Scatter and Gather pattern enables messages to be sent to multiple recipients and messages to be received back from each recipient. You can implement this pattern by using the Splitter pattern and the Aggregator pattern. You use the Aggregator pattern to assemble the results from using the Splitter pattern and put them under a Parallel Actions shape. For an example of the Splitter pattern, see SDK sample named Implementing Scatter and Gather Pattern at http://go.microsoft.com/fwlink/?LinkId=65185.


Sequential Convoy

The Sequential Convoy pattern enables multiple single items to join together to achieve something that an individual item cannot accomplish by itself. A sequential convoy is a set of related items that have a predefined order. Although the items do not have to be exactly the same, BizTalk Server must receive the items in a sequential order. For an example of this pattern, see http://go.microsoft.com/fwlink/?LinkId=56035.


Splitter

The Splitter pattern takes a single message and splits it into multiple messages. For an example of this pattern, see ConfirmOrderWithVendors.odx in File Inventory for the Business-to-Business Solution.


Suspend with Retry

The Suspend with Retry pattern enables the orchestration to suspend a message when there is an error. The suspension occurs within a loop so that the orchestration suspends, asks for intervention, and then retries the operation a fixed number of times. For an example of this pattern, see GetPurchaseOrder.odx in File Inventory for the Business-to-Business Solution.


BizTalk - Scatter / Gather Pattern

We recently encountered a BizTalk Orchestration Design problem: How do we maintain message flow when a message needs to be sent to multiple recipients, each of which may or may not send a reply, and then aggregate the response from all recipients into one message?

The Solution: One of BizTalk’s many powerful features is its ability to loosely couple messages, which allows for the subscription-based processing of messages. The ability to route messages based upon content filters makes BizTalk a great fit for the Scatter/ Gather pattern.

The Scatter/ Gather pattern is a method for broadcasting and processing messages in parallel. The "scatter" portion distributes a series of messages, all at the same time, and then an aggregator "gathers" the messages back into the main response before continuing.