Search code examples
biztalkbiztalk-2016

Debatching Biztalk flat file message into individual grouped flat files based on value


Have an issue where I am trying to debatch a flat file in BizTalk Server (comma delimited to tab-delimited) into individual flat files based on a value (in this example it would be PONumber) in the original file.

Sample input:

PartNumber,Weight,PONumber,Other
21519,234,46788,1
81919,456,47115,1
91910,789,47115,1

This would outcome into 2 messages such as:

PartNumber  Weight  PONumber    Other
21519   234 46788   1

and

PartNumber  Weight  PONumber    Other
81919   456 47115   1
91910   789 47115   1

I have seen similar things but no definite answers, or samples are dead links. Does anyone have a sample where they have done something like this or have a good solution?


Solution

  • Option 1: Convoy pattern

    Change your schema so that it has a max occurs of 1 for the PO line, this will debatch each line into it's own messages when it is received.

    Promote the PONumber so that it is a promoted property in the message context.

    Have an Orchestration that has a correlation set based on the PO number, and initialises this on the first receive shape.

    Have a receive shape with a following correlation that is in a wait shape inside a loop to receive all the other lines with the same PO number and combine them into a single message.

    Option 2: Staging database

    The other option is to just insert all of the rows into a SQL database, and then have a stored procedure that you poll that gets all the lines for a single PO.

    This can sometimes be simpler, and avoids the issue of Zombies as you can implement this as a messaging only pattern or using a simpler Orcherstration without a loop.