BizTalk Bootcamp - Day 3a Diary: Nuggets (Lab)
Continued from http://dotnet.org.za/willy/archive/2008/05/13/biztalk-bootcamp-day-2-diary-nuggets-schemas-maps-pipelines.aspx. This post summarises one of the last labs we did last night and which I dry-ran again this morning to get a clear understanding on what is going on.
Lab Scenario
Frequently, companies find it useful to break messages containing several hundred or thousand line items into individual messages for processing; for example, batches of invoices or orders that need to be updated separately. Tailspin Toys receives their store restocking requests containing multiple items, but the individual items contained therein need to be ordered from various vendors. In this lab, you will split these restocking messages for subsequent processing.
The following image is a summary:
If you are wondering, the magic of splitting StoreOrder is done by the DIS-ASSEMBLER of the receive Pipeline based on the envelope and BodyXPath properties if the RestockOrder message. The BodyXPath defines where the envelope ends and the body begins.
In other words, the receive pipeline splits the RestockOrder message into an envelope and line items, based on the SplitOrder schema. The LineItem_to_StoreLineItem maps the LineItem messages to StoreLineItems.
The property demotion (re-population) of the StoreNumber element in the StoreLineItem is done automatically by the XMLTransmit send pipeline. If you set the pipeline to PassThruTransmit, the magic of default demotion ends.
StoreOrder Schema
SplitOrder Schema
LineItem Schema
StoreLineItem Schema
LineItem_to_StoreLineItem Map
Set the Value property for the StoreNumber field to <empty>, which ensures that the map creates the StoreNumber field, although it has no value at mapping time.
Promoted Fields
What if we suddenly have a flat file coming in?
Some rough notes:
- Must use a pipeline to split the incoming message.
- Create header, body and trailer schemas for the incoming message.
- Promote elements in the header if necessary, i.e. if needed during mapping process, and create a property schema.
- Promote elements in the outgoing message schema, if necessary. Add property schema of (3) to the promotion and match the relevant values. In fact the property schema is now shared by the incoming header and the outgoing message.
- We need a custom Flat File receive Pipeline, which:
- Includes two flat file disassemblers, one which processes a single message and the other a batch of messages.
- Take note that flat files are split "all or nothing", i.e. if the last data element is bad, none are split
- We need a custom Flat File Send Pipeline, which:
- Includes a flat file assembler
- Set the custom receive and send pipelines for the receive and application, otherwise we will receive, pass-through and resend message with no changes.
- Optionally create a utility application, set a send port, with a filter ErrorReport.ErrorType == FailedMessage, to trap and process any failures.
HINT: If you have common artifact, i.e. schemas and pipelines, you can set a reference to the common application containing the artifacts. Go to your application, right-click, Add and choose References.
HINT: Has the schema changed? Remember, the host caches the schemas. Select Platform Settings -> Hosts and restart the host instance to refresh the cache.
HINT: Q: Where does one find properties such as FailedMessage? A: It is a keyword ... would be great to have a drop down in the admin tool q;-|
Now for day 3 stuff. Watch the space ...