Click here to Skip to main content
Click here to Skip to main content

BizTalk Enterprise Integration Patterns - Part 2

By , 25 Apr 2006
Rate this:
Please Sign up or sign in to vote.

Introduction

This article is the next part of the BizTalk Integration pattern series. This article discusses message oriented systems pattern known as Claim Check Pattern.

Setting the Context

In message oriented systems, during the processing of large messages we would want to remove uninteresting fields, but only temporarily and then later, when the processing is complete, we would like to add back the removed part of the message. In other words, a message may contain a set of data items that may be needed later in the message flow, but that are not necessarily required, for all intermediate processing steps. So we don't want to carry such huge amount of data in the intermediate steps, which can make debugging difficult or can cause performance degradation.

ClaimCheckPattern

Scenario - A Store Info Processing Message

StoreInfo

Consider a scenario where a StoreInfo processing message needs to be processed. The elements MsgID and MsgContent are the only fields required for processing the message.

The Claim Check Pattern Implemented as an Orchestration

Orchestration

Quick Explanation...

  1. A Store message is received by the activatable "Receive Shape", which activates this orchestration.
  2. The MsgID is extracted from the message and assigned to messageId variable.
    messageId = StoreInMsg.Message.MsgID;

    Orchestration

  3. A WebService Request message is formed.

    NOTE: The variable declared in the Web Service is of type XmlDocument and hence it can accept any schema.

    WSRequest.messageId = messageId;
    WSRequest.xDoc = StoreInMsg;
    System.Diagnostics.EventLog.WriteEntry
    	("Claim Check Orchestration", "Message ID: " + 
    	System.Convert.ToString(messageId));
  4. The Web request is sent to the web service and the message is persisted.
  5. The "Decide" shape is used to classify the message as "safe" and "unsafe". This is just an example of some processing logic.
  6. Once the processing is complete, again another Web Request is issued to get back the persisted message.
    WSRequest2.messageId = messageId;
  7. The Web response is now integrated with the processing results and sent to Output Port.
    StoreOutMsg = WSResponse2.RetrieveMessageResult;
    StoreOutMsg.Message.MsgContent = messageContent;
    System.Diagnostics.EventLog.WriteEntry
    	("Claim Check Orchestration", "Message Content: "+ messageContent);

The Web Service Code...

The message is stored in the Cache object, using the messageID as the key.

[WebMethod]
public bool PersistMessage(int messageId, XmlDocument xDoc)
{
    try
    {
        this.Context.Cache.Add(messageId.ToString(), 
		xDoc, null, Cache.NoAbsoluteExpiration, 
        Cache.NoSlidingExpiration, CacheItemPriority.High, null);
        
        return true;
    }
    catch
    {
        return false;
    }
}

The message is retrieved from the Cache object, using the messageID as the key.

[WebMethod]
public XmlDocument RetrieveMessage(int messageId)
{
    try
    {
        XmlDocument xDoc = (XmlDocument) 
		this.Context.Cache[messageId.ToString()];
        
        this.Context.Cache.Remove(messageId.ToString());
        
        return xDoc;                
    }
    catch
    {
        return new XmlDocument();
    }
}

Executing the DEMO

Input File

InputXML

The InputXML file would have a blank MsgContent element.

Event Viewer

Evtvwr

Observe the event viewer for the messages.

Output File

OutputXML

The OutputXML file would have a populated MsgContent element.

About the Downloadable Code

  • Unzip the Web Service with the folder names into the C:\inetput\wwwroot directory and setup the web service.
  • Unzip the BizTalk project zip file with the folder names in the C:\ drive.
  • The folder KeyAndBindings contains the Bindings.xml file, which can be imported after the solution is built and deployed.
  • Place the "StoreInfo_1.xml" in the In folder and check the Out folder for the response.

Some Takeaways

  1. Always select the "WebPortType" created when the "Web Reference" is added to the project, while creating "Web Ports" in the Orchestration.

Additional References

  1. The Architecture Journal - Messaging Patterns in Service Oriented Architecture, Part 2
  2. Enterprise Integration Patterns - Claim Check Pattern

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Naveen Karamchetti
Architect AT&T Wi-Fi Services
United States United States
Naveen has done his Masters (M.S.) in Computer science, has started his career programming the mainframes and now has more than a decade of programming, development and design experience. Naveen has a sharp eye and keen observation skills. Naveen has worked for several companies and strived hard to build large scale business applications and bringing better solutions to the table.
Quite recently Naveen has built a fairly complex integration platform for a large bank. His hobbies include training, mentoring and research. Naveen spends his free time visiting National Parks nationwide.
 
Naveen has developed the BizTalk Control Center (BCC)
http://biztalkcontrolcenter.codeplex.com

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 25 Apr 2006
Article Copyright 2006 by Naveen Karamchetti
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid