Moustafa Refaat
Login   Search
Skip Navigation Links
Home
Publications
Service Offerings
Downloads and Samples
My Resume
Endorsements
Contact Me
Books
Technical Articles
Software Packages
Scroll up
Scroll down
BizTalk The Practical Course
Mastering The BizTalk Technical Interview
Soduku:Challenging Puzzels
Scroll up
Scroll down
Design Patterns Review
Software Architecture Basics Review
Simplified BizTalk Content Based Routing for a Pass_Throu data
An Extensible Light Xml Rules Engine Component
Secure Messaging Solution
Create a SQL Database Programmatically
BizTalk Unzip Adapter
Implementing Singleton pattern with BizTalk Orchestrations
Developing BizTalk Custom Adapters
The BizTalk ESB Toolkit 2.0 experience Series
Scroll up
Scroll down
Setting the ESB Toolkit on the 64 Bit Machines
How The ESB Works
Sample Custom Resolver
Scroll up
Scroll down
Recent Training
Scroll up
Scroll down

News List

  • iBTSInterview (BizTalk Technical Interview) is available on iPhone and iPad
  • Toronto Code Camp Presentation is uploaded
  • BizTalk: The Practical Course is recommended by Micorsoft
  • Canadian Gigs Network (www.CanadianGigs.Net) a job web site focusing on Canadian Jobs
  • BizTalk Technical Interview Preparation
  • GT-DataSafe© Online Backup for Amazon Storage Services 3.0 is released
  • Soduku Challenging Puzzles
  • BizTalk: The Practical Course
  • Mastering The BizTalk Technical Interview is Published Now Avaliable on iPhone an iPad

Technical Articles

  • JavaScript, and SharePoint Calculated Field Trick
  • Scrum Pitfalls
  • Customizing the XSLTListView Web Part
  • SharePoint List Simplified Configuration Store
  • WCF and xsd:choice how to implement!
Skip Navigation Links>Publications>Technical Articles>Simplified BizTalk Content Based Routing for a Pass_Throu data
 I had simple task, I had image files that need to be routed (“copied”) to another location based on some field being set inside the image metadata. I devised a simple solution that consists of a simple pipeline component that promotes the filed into the Message Context, create a dummy schema with promoted field. Use the pipeline component in a custom pipeline. This solution would read the information and promote the field values if they exist without publishing the whole image into the message box database. Delivering performance similar to using the standard pass-throu pipeline.  Bellow you can find the pipeline and the sample code of the component

 

/// <summary>

        /// Implements IComponent.Execute method.

        /// </summary>

        /// <param name="pc">Pipeline context</param>

        /// <param name="inmsg">Input message.</param>

        /// <returns>Processed input message with appended or prepended data.</returns>

        /// <remarks>

        /// IComponent.Execute method is used to initiate

        /// the processing of the message in pipeline component.

        /// </remarks>

        public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)

        {

            try

            {

                IBaseMessagePart bodyPart = pInMsg.BodyPart;

                string imgsrc = null;

                                if (bodyPart != null)

                {

                    Stream srcs = bodyPart.GetOriginalDataStream();

                    StreamReader tr = new StreamReader(srcs);

                    string contents;

                    string beginCapture = "<photoshop:Source>";

                    string endCapture = "</photoshop:Source>";

                    int beginPos;

                    int endPos;

                        contents = tr.ReadToEnd();

                        Debug.Write(contents.Length + " chars" + Environment.NewLine);

 

                    beginPos = contents.IndexOf(beginCapture, 0);

                    if (beginPos > 0)

                    {

                        endPos = contents.IndexOf(endCapture, 0);

 

                        Debug.Write("xml found at pos: " + beginPos.ToString() + " - " + endPos.ToString());

 

                        imgsrc = contents.Substring(beginPos + beginCapture.Length + 1, (endPos - (beginPos + beginCapture.Length + 1)));

 

                        Debug.Write("Xml len: " + imgsrc.Length.ToString() + " Imgsrc = " + imgsrc);

 

                    }

// return the cursor to the start of the stream

                    srcs.Seek(0, SeekOrigin.Begin);

 

                }

                pInMsg.Context.Promote("Source", @"http://MoustafaRefaat.ImagingPipeLine.PropertySchema.PropertySchema", imgsrc);

            }

            catch (Exception ex)

            {

                Debug.WriteLine(ex.ToString());

            }

            return pInMsg;

        }

 

If you have any questions I would love to hear from you

Copyright © Moustafa Refaat 2004 - 2009. All Rights Reserved.