Introduction:  As a BizTalk consultant, you had an assignment that a service provider asked you to enhance the existing BizTalk solution. They are receiving different flat files from different customers and each customer has a different flat file format. All customers send these flat files in one receive path with a specific unique file name format####YYYYMMDDHHMMSSNNN.txt To implement this scenario there is great article is present here: BizTalk Server: Dynamic Schema Resolver Real Scenario.

Scenario: I am just trying to extend this article by removing creation of multiple receive location here. After implementing this article we just need to create a receive location each time whenever we will add a new customer. Now think you achieved a new height in your business and now you are dealing with more than 100 clients for the same process and receiving files from each customer daily basis. So now you need to add new customer today and you just opened the BizTalk Admin console and respective application and there are more than 100 receive location already there so now it will be little bit difficult to manage this scenario due large no of receive location (it may be or may be not).

Problem: Problem is here that every time we need to create a new receive location and with the time the number of receive location will get increase and will be difficult to manage.

Solution: In this type of scenario we can go ahead with dynamic receive location. But how can we implement this dynamic receive location because there is no such binding is available in BizTalk for receive port.

How it will work:

How implement dynamic receive locations:

To implement dynamic receive location we need to create a good database strategy to store all required information required to receive a files from any location like from folder location , sftp server ,email server, etc.

Here I will take File Folder location (File Adapter) as example and same logic we can apply for other adapters as well.

So to read a file from folder location what are the properties we configure in File Adapter? Mainly below are

File Location, File Mask, Schedule window etc.

So let’s create a table to store the above information:

Id

FileLocation

FileMask

Schedule Start

Schedule End

1

E:\Files\Clinet1\

*.txt

CRON EXPRESSION

CRON EXPRESSION

2

E:\Files\Cleint2\

*.xml

CRON EXPRESSION

CRON EXPRESSION

To Schedule Window (start & End ) we can use CRON EXPRESSION and you can get lots of example how decode cron expression in sql server.

So now next step:

We need a stored procedure which will return all the above information’s in xml format. Let’s assume the xml format will be like below:

<File>

   <Clients>----This will be repeating record node so can accomplished many clients information.

         <FileLocation>

         <FileLocation>

         <FileMask>

         </FileMask>

  </Clients>

</File>

DynamicFile Receiver Pipeline: This pipeline will read the xml generated from stored procedure and based one location and file mask it will move the file from clients specific locations to process common location. Once files will come to common location then the Dynamic Schema Resolver Pipeline Component will start work. To move file from client folders to common folder we can use File.Move function.

Assumptions: Here I assumed the user have access to read and write permission on both folder locations.