none
BizTalk - Orchestration Multiple Receive Shapes - Filename similar RRS feed

  • Question

  • Hey,

    I've got a new one I can't quite seem to find on Google.

    I've got an orchestration that has to pickup 2 files.

    The first is a csv file like: "invoiceregisterB3472013041212488417.csv", the second is a pdf like: "B3472013041212488417.pdf".

    How can I make the correlation based on the name of the files? (as you can see the last part of the csv is the same as the whole of the pdf name, without the extensions). The Csv would be the first one to arrive and would trigger the orchestration (more manipulations will be done in the orchestration, depending on the data in the csv-file).

    Does anyone know any (easy) way to make this link?

    Thank you!

    Tuesday, May 7, 2013 12:18 PM

Answers

  • Hi Sob,

    One of the options for you is:

    • Create two Receive locations to receive *.csv and *.pdf files.
    • Create a custom receive pipeline component where you can extract the part of the value from the filename which you want the correlation to be based on. i.e for “"invoiceregisterB3472013041212488417.csv extract “B3472013041212488417” and from pdf file extract the full name with out extension. Promote the extracted value to custom filed as part of property promotion which you can use in your correlation. something like this
    string sFileName = context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties").ToString();
    string sCorrlationToken = String.Empty;
    if (Path.GetExtension(sFileName).ToUpper() == "CSV")
    {
    	string consStaticFileName = "invoiceregister";
            string sFileNameWithoutExt = Path.GetFileNameWithoutExtension(sCSVFileName);
            //Extract B3472013041212488417
            sCorrlationToken = sFileNameWithoutExt.Substring(consStaticFileName.Length);
    }
    else if (Path.GetExtension(sFileName).ToUpper() == "PDF")
    {
    	sCorrlationToken = Path.GetFileNameWithoutExtension(sCSVFileName);
    }
    //Promote the Correlation
    pInMsg.Context.Promote("CustomCorrlationToken", "http://PropertySchema.IAProperty", sCorrlationToken);
    • Use this custom receive pipeline component in a custom receive pipeline which you shall use it in the receive locations for *.csv and *.pdf.
    • Develop Sequential convey using this promoted property as the correlation token.

    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    • Edited by M.R.Ashwin Prabhu Tuesday, May 7, 2013 1:41 PM Added Code sample
    • Proposed as answer by Mohit Kumar Gupta Wednesday, May 8, 2013 7:58 AM
    • Marked as answer by Sorbjar Wednesday, May 8, 2013 8:32 AM
    Tuesday, May 7, 2013 1:00 PM
  • What you'll need is a Convoy pattern, Sequential or Parallel.  Either is driven by two Correlated Receive Shapes in a single Orchestration.  That's the basics.

    I've found it tricky to assume that one event will always and forever precede another so I'd favor a Parallel Convoy.  Either way, you'll need to setup a Promoted Property to correlate on.

    In your case, you have two options, 1) promote the property in a custom Pipeline Component, 2) promote the property in an utility Orchestration.

    So, the easy, and pretty much only way:

    1. Create a Property Schema defining the Message Context Property you'll Promote

    2. Parse-out and Promote the ID value to you custom context property.

    3. Your processing Orchestration will have two Activating Receive Shapes in a Parallel Shape each Initializing and Following the same Correlation Set.

    4. Be sure to wrap each Receive in a Scope with a timeout value, otherwise, it will wait forever if one of the messages fails to arrive.

    • Marked as answer by Sorbjar Wednesday, May 8, 2013 8:32 AM
    Tuesday, May 7, 2013 1:18 PM
    Moderator

All replies

  • Hi,

    You can achieve this by using correlation based on receive port name. You can use Sequntial convoy for this & use CSV file to create an instance of the Orchestration & then you can receive PDF file. For implementation of Sequential convoy you can visit this link.

    Regards

    Rahul Madaan

    BizTalkVillage.blogspot.com

    Tuesday, May 7, 2013 12:36 PM
  • Hi Sob,

    One of the options for you is:

    • Create two Receive locations to receive *.csv and *.pdf files.
    • Create a custom receive pipeline component where you can extract the part of the value from the filename which you want the correlation to be based on. i.e for “"invoiceregisterB3472013041212488417.csv extract “B3472013041212488417” and from pdf file extract the full name with out extension. Promote the extracted value to custom filed as part of property promotion which you can use in your correlation. something like this
    string sFileName = context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties").ToString();
    string sCorrlationToken = String.Empty;
    if (Path.GetExtension(sFileName).ToUpper() == "CSV")
    {
    	string consStaticFileName = "invoiceregister";
            string sFileNameWithoutExt = Path.GetFileNameWithoutExtension(sCSVFileName);
            //Extract B3472013041212488417
            sCorrlationToken = sFileNameWithoutExt.Substring(consStaticFileName.Length);
    }
    else if (Path.GetExtension(sFileName).ToUpper() == "PDF")
    {
    	sCorrlationToken = Path.GetFileNameWithoutExtension(sCSVFileName);
    }
    //Promote the Correlation
    pInMsg.Context.Promote("CustomCorrlationToken", "http://PropertySchema.IAProperty", sCorrlationToken);
    • Use this custom receive pipeline component in a custom receive pipeline which you shall use it in the receive locations for *.csv and *.pdf.
    • Develop Sequential convey using this promoted property as the correlation token.

    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    • Edited by M.R.Ashwin Prabhu Tuesday, May 7, 2013 1:41 PM Added Code sample
    • Proposed as answer by Mohit Kumar Gupta Wednesday, May 8, 2013 7:58 AM
    • Marked as answer by Sorbjar Wednesday, May 8, 2013 8:32 AM
    Tuesday, May 7, 2013 1:00 PM
  • What you'll need is a Convoy pattern, Sequential or Parallel.  Either is driven by two Correlated Receive Shapes in a single Orchestration.  That's the basics.

    I've found it tricky to assume that one event will always and forever precede another so I'd favor a Parallel Convoy.  Either way, you'll need to setup a Promoted Property to correlate on.

    In your case, you have two options, 1) promote the property in a custom Pipeline Component, 2) promote the property in an utility Orchestration.

    So, the easy, and pretty much only way:

    1. Create a Property Schema defining the Message Context Property you'll Promote

    2. Parse-out and Promote the ID value to you custom context property.

    3. Your processing Orchestration will have two Activating Receive Shapes in a Parallel Shape each Initializing and Following the same Correlation Set.

    4. Be sure to wrap each Receive in a Scope with a timeout value, otherwise, it will wait forever if one of the messages fails to arrive.

    • Marked as answer by Sorbjar Wednesday, May 8, 2013 8:32 AM
    Tuesday, May 7, 2013 1:18 PM
    Moderator