Martijn's blog - E-Commerce, EAI, BizTalk and .NET

2004/06/30

Another BizTalk 2004 performance hint

Another BizTalk 2004 performance hint comes from TechEd 2004 as well: if you're sending multiple messages at once, wrap it in an atomic scope. This will create 1 persistence point instead of n (n being the number of messages you send). Persistence points are points at which BizTalk serializes the orchestration state into the MessageBox, draining the system from resources.

Send ports, performance issue

Something I've picked up at TechEd 2004 Europe which I hadn't considered myself yet: don't use XmlTransmit on sendports unless you need to demote properties back into the message. This prevents a performance drain!

Easily undeploy an assembly

Using this console application you can easily undeploy assemblies from BizTalk. It saves the current binding information into an XML file for easy restore. Things that might be improved: 1) Kill existing orchestrations running from the BizTalk environment, to ensure the assembly can actually be deployed. Currently, false positives might be generated if orchestration instances still exist. 2) bugs? 3) It's poorly documented, if anyone offers...

UPDATED: Here it is

File adapter with regular expressions

I've altered the FILE adapter SDK sample so that you don't have to create a receive location for each file extension you wish to pick up. It accepts a regular expression for the receive location. It's a simple modification, put I was creating lots of receive locations, one for each filetype I had to pick up and got fed up with it. Let me know what you think!

In PickupFilesAndSubmit (DotNetFileReceiverEndpoint.cs), change the lines
DirectoryInfo di = new DirectoryInfo(this.properties.Directory);
FileInfo[] items = di.GetFiles(this.properties.FileMask);


into:

FileInfo[] items = GetFilesRegex(this.properties.Directory, this.properties.FileMask);


and add the function GetFilesRegex() where you want it:

/// <summary>
/// This method retrieves all files from a given folder, matching
/// a regular expression in their filename
/// </summary>
/// <param name="path">The folder to enumerate
/// <param name="regularExpression">the regular expression string for matching the files</param>
/// <returns>an array containing the found filesystem entries</returns>
public static FileInfo[] GetFilesRegex(string path, string regularExpression)
{
 // queue == FIFO
 Queue q = new Queue();

 DirectoryInfo di = new DirectoryInfo(path);

 foreach(FileInfo fi in di.GetFiles())
 {
  // see if we match our regular expression
  if(Regex.Match(fi.Name, regularExpression).Success)
  {
   // we do, enqueue the file
   q.Enqueue(fi);
  }
 }

 // copy the queue back into an array of files
 FileInfo[] fia = new FileInfo[q.Count];
 q.CopyTo(fia, 0);

 return fia;
}


You're done! Now configure the adapter (file mask) with a regular expression: (?i).*\.((dw)|(pd))f