martedì, febbraio 01, 2011

BizTalk Pipeline Template (Visual Studio 2005)

During years of BizTalk development, I’ve finalized a set of standard pipeline components I use on every pipeline of mine.

What these pipeline components do is not important here (one is the BAM Pipeline Component depicted here, other realize streaming backup, other trace diagnostic information, etc) but the point is that they are came with every pipeline I realize.

I even realized enhanced version of default pipelines (XmlTransmit, XmlReceive, PassThruTransmit, PassThruReceive) already instrumented with these pipeline components.

Unfortunately sometimes the default pipelines are not enough and I need to implement a new pipeline to support custom behaviors (i.e. custom message debatching, disassembling and so on) and, since standard visual studio templates give us an empty pipeline, I have to add again all pipeline components and configure each one with its default parameter.

This is an error prone task and adding a component can be easily forgot by developers new to our infrastructure and this may lead to unpleasant situation as where you told customer “yes enabling backup/BAM/Diagnostic is just a configuration” only to discover a moment after that that particular flow uses a custom pipeline and its developer “forgot” to put in our default pipeline components (therefore requiring a modification, recompilation, redeploy and reconfiguration of all the ports impacted by the modification).

A simple solution to the problem would be writing a “pipeline template” already set with our pipeline components all ready and set.

BizTalk 2006/R2

What we need, in Visual Studio terminology, is an Item Template but, when we try to select the “Export Template…” menu item as depicted here we will se that the option is grayed out for BizTalk projects.

This is not unexpected: when VS2005 was finalized and embraced MSBuild as project format, BizTalk projects retained the old project format (first true integration between MSBuild and BizTalk came in 2009 edition) and therefore we expected something similar.

Inspecting the BizTalk installation directory, inside the Developer Tools directory we find some interesting directories such as BizTalkProjects or BizTalkProjectItems… since we’re interested in Item Templates is natural to open the BizTalkProjectItem directory:

image

Inside that directory we can see all biztalk item templates used by BizTalk:

  1. BTSMap.btm: Template for empty map
  2. BTSSchema.xsd: Template for empty schema
  3. BTSReceivePipeline.btp: Template for empty receive pipeline
  4. BTSSendPipeline.btp: Template for empty send pipeline
  5. BTSService.odx: Template for empty orchestration.
  6. BTSPropertySchema.xsd: template for empty property schema item.
  7. FFSchema.xsd: template for empty flatfile schema.
  8. BTSFlatFileSchema.vsz: probably, matches FlatFileSchema Wizard (see below)

A quick comparison between BizTalk “add new item” screen and directory content show us that they’re somehow related:

image

Inspecting directories (Map Files, Pipeline Files, etc) show us just a single *.vsdir file for each directory.

Both vsz and vsdir files are Visual Studio standard file formats:

  • Vsz is used to invoke a wizard and pass parameters to it (and therefore our idea that BTSFlatFileSchema.vsz is related to FlatFileSchema Wizard option is confirmed).
  • Vsdir is used instead to provide information about how display items in “Add Items” dialog.

Adding template files

The first step we have to do is to create our pipeline templates as normal pipelines in a biztalk solution.

Then we take btp files containing our templates and copy them inside the BizTalkProjectItems directory.

Modifying BTSPipelines.vsdir

Then we start modifying the file BTSPipelines.vsdir in Pipeline Files subdirectory.

We just need to add a row for each btp template added, below a comparison between default BTSTransmitPipeline.btp row and my custom MySendPipeline.btp template.

For field description refer to Vsdir msdn page, what I would like to underline here is that parameters starting with ‘#’ character are simply a reference to a resource identifier and can be replaced directly with a string

Name Default pipeline My custom pipeline
RelPathName ..\BTSTransmitPipeline.btp ..\MySendPipeline.btp
{clsidPackage} {ef7e327e-cd33-11d4-8326-00c04fa0ce8d} {ef7e327e-cd33-11d4-8326-00c04fa0ce8d}
LocalizedName #228 My Custom Send Pipeline
SortPriority 121 121
Description #229 My Send Pipeline instrumented with custom components.
DLLPath or {clsidPackage} 0 0
IconResourceId 233 233
Flags 0 0
SuggestedBaseName #230 #230

 

Modifying BTSProjectItems.vsdir

To complete our work we need to add the row also to the BTSProjectItems.vsdir file contained in the BizTalkProjectItems directory.

The row is exactly the same added in the previous section to the BTSPipelines.vsdir file, the only thing that changes is obviously the RelPathName because now the MySendPipeline.btp file is in the same directory of the vsdir file so there’s no need to use the ‘..\’ prefix.

Below again the comparison of a standard template and my custom template.

Name Default pipeline My custom pipeline
RelPathName BTSTransmitPipeline.btp MySendPipeline.btp
{clsidPackage} {ef7e327e-cd33-11d4-8326-00c04fa0ce8d} {ef7e327e-cd33-11d4-8326-00c04fa0ce8d}
LocalizedName #228 My Custom Send Pipeline
SortPriority 121 121
Description #229 My Send Pipeline instrumented with custom components.
DLLPath or {clsidPackage} 0 0
IconResourceId 233 233
Flags 0 0
SuggestedBaseName #230 #230

Choosing “Add New Item…” will show us our new pipeline template, ready to be used as can be seen below.

image

Unfortunately, I was unable to add references for my custom components directly when adding my custom template, therefore, once added the new pipeline from my template, I need to add reference by hand before being able to compile it.

Conclusion

I’ve focused on Pipeline templates but, obviously, the same process depicted above will allow us to create template for maps (btm), Orchestrations (odx) or Schemas (xsd).

The procedure anyway will work only for Visual Studio 2005 (and therefore to BizTalk 2006/R2), this because starting from BizTalk 2009 (Visual Studio 2008) BizTalk Project became true MSBuild projects and therefore Item Templates are more similar to standard visual studio item templates and less a custom wizard extension.

In the next post we will see how to obtain the same results also on BizTalk 2009

Nessun commento: