none
Can custom receive pipeline component drop files to output folder?

    Question

  • I'm receiving a flat file and use my receive pipeline component to validate the content. If there is anything wrong, I'd like to drop the flat file to an output folder and stop the process. I know I can create a file and write to it in C#. Does BizTalk have some standard way to do it? How can pipeline stop the process? What pInMsg.BodyPart should be?

    Thanks!

     
    Wednesday, May 23, 2012 8:21 PM

Answers

  • Following two ways IMO:

    1. In the custom pipeline which you are using to validate the message, write something like

    If ( MessageValidated== true) 

    return pInMsg

    Else

    // Save the message stream to a folder/archive location using IO methods

    return null;

    This will return null the to next pipeline stage and message will not be routed to the BizTalk messagebox hence nothing will happen.

    1. Another way would be,
    2. In the custom pipeline component, promote some custom context property and attach that with the message only when the message validation gets failed, and use a send port to subscribe the message and save it to a folder location

    If ( MessageValidated== true) 

    return pInMsg

    Else

    // Promote some custom context property 

    return pInMsg;

    I hope this helps.


    HTH,
    Naushad Alam

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer
    alamnaushad.wordpress.com
    My new TechNet Wiki "BizTalk Server: Performance Tuning & Optimization"


    Wednesday, May 23, 2012 8:27 PM

All replies

  • Following two ways IMO:

    1. In the custom pipeline which you are using to validate the message, write something like

    If ( MessageValidated== true) 

    return pInMsg

    Else

    // Save the message stream to a folder/archive location using IO methods

    return null;

    This will return null the to next pipeline stage and message will not be routed to the BizTalk messagebox hence nothing will happen.

    1. Another way would be,
    2. In the custom pipeline component, promote some custom context property and attach that with the message only when the message validation gets failed, and use a send port to subscribe the message and save it to a folder location

    If ( MessageValidated== true) 

    return pInMsg

    Else

    // Promote some custom context property 

    return pInMsg;

    I hope this helps.


    HTH,
    Naushad Alam

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer
    alamnaushad.wordpress.com
    My new TechNet Wiki "BizTalk Server: Performance Tuning & Optimization"


    Wednesday, May 23, 2012 8:27 PM
  • I like the second approach. That way the output location can be configured by the port binding xml instead of hardcoded or extra code that retrieves the configuration from somewhere else.

    My concern is my message content is text file instead of xml. So I can promote context  properties that are not related to my message content?

    Thanks for your response!

    Wednesday, May 23, 2012 8:58 PM
  • Yes, Sure you can do that. I have used them a lot. 

    Below steps you would need

    1. define a  property schema
    2. define a property
    3. add code in your custom pipeline component method to promote the custom property , Please refer this similar article. 

    One more way, Instead of using a custom context property, you can use/promote properties from ErrorReport class and use them. 


    HTH,
    Naushad Alam

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer
    alamnaushad.wordpress.com
    My new TechNet Wiki "BizTalk Server: Performance Tuning & Optimization"

    Wednesday, May 23, 2012 9:32 PM
  • Thanks for pointing out another approach!
    Wednesday, May 23, 2012 9:52 PM
  • Hi,

    Ya u can surely do it and it is straight forward.

    If there is any error in the flat file you could very easily have the InMsg to a IBaseMessage and promote any property such as MsgType to a custom MessageType and create a send port which has a filter expression of BTS.MessageType=Your Custom MsgType which you promoted.

    Have a XML transmit if u need the XML type or have a flat file pipeline to have the output as the Flat file received..


    Regards Ritu Raj When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    • Proposed as answer by Pi_xel_xar Thursday, June 07, 2012 5:44 PM
    Thursday, June 07, 2012 5:43 PM