BAM, BRE, and too much time on my hands
Having a 5 hr flight twice a week had left me with enough time on my hands that I have an opportunity to explore some of the finer things of BizTalk. The first example is a client had asked me to have an Interchange router. Like almost all of the business I have been involved in, it is EDI. To give a 2 sentence description of EDI, an EDI document can have multiple Interchanges, each Interchange can have multiple Functional Groups, and each Functional Group can have multiple Transactions. Each Interchange starts with ISA and ends with IEA, each Functional Group starts with GS and ends with GE, and each Transaction starts with ST and ends with SE.
The client had wanted me to build an Interchange Router, take each interchange in the file and based on certain criteria send it to different locations. Also if it was an 856, some values in the ISA needed to be changed. If an interchange came from a particular vendor, it needed to be routed to a seperate location.
I put together the project, first building a Interchange, calling the schema single.xsd, I then imported it to the multiple interchange schema, oddly enough called Multiple.xsd. I created the flat file recieve pipeline and send pipeline that consumes and delivers their respective files. After the multiple interchange file is consumed, I create what I like to call is a context message. This message will be manipulated by the BRE. I then call the BRE (Server Info), instead of a Call Rule shape, I create an array, and send it the context message I just created which will retrieve the server name where the MessageBoxDB and BAMPrimaryImport data exists.
I then call the DirectEventStream and write the input file information directly to the BAMPrimaryImport database. Because I set the second argument of DirectEventStream to ‘0′ I need to flush it after it is completed.
I then split up the document, call a Business Rule (Router) to determine where the single interchange destination is, and make modifications to the interchange if it was a 856. I then took that specific information and logged it to BAM, and using a relationship, I was able to tie it into the file information.
You will have to use the BM.exe to deploy various bam views, and the Business Rules Deployment wizard to import the vocabularies and policies into the BRE.
Attached is my finalized project, which was over and above what the client was expecting, as now there is a log of what was received, and what was sent out.
Here is the link to the zipped 2K4 example