Parallel Convoys (Concurrent Receive) in BizTalk

In the past, I have tended to focus on sequential convoys.  Now, I decided to take a look at Concurrent Convoys.  First off, I was sure in older versions of the documentation they were called Parallel Convoys?  Maybe I’m mistaken or maybe the name changed over the past few months….  In any case, I will get with the times and call them Concurrent Convoys.  No matter what you call them, the power and usefulness of this type of convoy is the same.



Why use Concurrent Convoys?  Concurrent convoys allow you to receive multiple items in any order that all need to be processed by the same Orchestration before the next step in the process can happen. 



Setting up and using a Concurrent Convoy is rather straight forward.  All you have to do is drop a Parallel Shape inside your Orchestration.  Then, drop in your multiple Receive Shapes. If this is the first shape in your Orchestration then each Received must be set with Activate = True and all must initialize the same Correlation Set.  Otherwise, they must all follow the same Correlation Set that was initialized by a Send Shape.  That is all your need to do!



I have included a sample with two different Orchestrations.  One Orchestration shows a Concurrent Convoy with Active Receives and one without Active Receives.



The Orchestration with Activate Receives has two sets of sample files.  The set with ID 100 will produce 8 total records in the output file.  The set with ID 500 produces 6 records.  Note that since all three messages arrive on different ports, Receive Port mapping is possible to get all inbound documents into a common format (not shown in my sample). 



The Orchestration without Activate Receives uses the same set of sample files but it requires a Start Message to be received and a message to be sent out to initialize the correlation.  This will produce the same output of 8 and 6 records.  In this Orchestration, all the Receives uses the same Receive Port.



For information on how to run the samples, please see the Read Me file.


Make sure you keep an eye on the BTSSubscriptionViewer tool (located in the SDK).  Note the differences between the two Orchestrations.



DOWLOAD: Sample Concurrent Receive Convoys



Bonus:  I also show a simple say to merge all three messages together into a single output.  This uses a map inside the Orchestration. 

Parallel Convoy Message Processing

This sample shows how to use a simple Concurrent (Parallel) Convoys inside an Orchestration. For more information on Convoy, be sure to read the Convoy Deep Dive White Paper.

This sample also shows an example of multi-message mapping inside an Orchestration.

This sample should work for BizTalk 2004 and BizTalk 2006.

Get more information from the original blog post on this topic: https://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalk/archive/2004/11/08/parallel-convoys-_2800_concurrent-receive_2900_-in-biztalk.aspx

BizTalk Code Behind

I was chatting to my colleague Charles Young earlier today and it reminded me of an idea that I had a while back. Wouldn’t it be nice if, instead of having expression shapes (and the awful expression editor window 😉 ), we instead had an ASP.NET-like “code behind” model allowing us to use any .NET language, and not have to worry about working within the restrictions of XLANG/s. Of course I appreciate the design principle that Orchestrations shouldn’t be littered with code and you should instead be calling out to .NET classes to do the real work, but the developer experience of ASP.NET code-behind development is just so appealing. Orchestrations are rather like ASP 1 for calling code in their current form.


That led me to thinking that effectively you’d have anonymous blocks of code (a la .NET 2.0) subscribing to certain events in the orchestration; following that thought, if you could create subscriptions for blocks of code, you’d be opening up a whole world of possibilities (or, maybe, pain). Then again, that’s not such a big step from the Aspect Oriented ethos – Aspect Oriented Biztalk anyone? 😉

Administrating multiple BizTalk 2004 environments from a single machine / Remote HAT

It can turn out to be useful to use Health and Activity Tracking (HAT) and the BizTalk
Server Administration Console “remotely” (that is, from a machine other
than one of the actual servers in the BizTalk group.)  This can be the case if
you have multiple environments to administer, and/or using Remote Desktop is not desirable
or available.

It should be noted that to accomplish this, you technically have to have the “administrating
machine” join the BizTalk Group – though since you won’t
have any host instances defined on the machine, that isn’t as significant as
it sounds.  You are essentially just configuring the machine to point at a particular
BizTalk management database, and configuring some WMI information.  The “administrating
machine” does not appear in the “Servers” node of the BizTalk
Administration Console.

It should also be noted that you will need to be in the “BizTalk Administrators”
Windows group for the BizTalk environment you want to manage. 

To get started, the “administrator” should do an “Admin-only”
install of BizTalk on the machine they will be using, where the installation options
for BizTalk look like this:

Then, on the desktop, the administrator should put a shortcut to a script that looks
like the script below.  This script simply reminds the user what BizTalk Group
they are currently administrating, and confirms they want to switch:

If you select OK, you get another warning:

This is basically warning someone who has a full-blown BizTalk installation on their
machine that they really don’t want to remove their current configuration unless
they happen to have a saved configuration file from their last run of ConfigFramework.exe.

If you select OK, the “ConfigFramework.exe” utility is run (from BizTalk’s
installation directory) with the /u switch, to remove the current configuration. 
Afterwards, ConfigFramework.exe is run normally, and the only option you will have
(for an admin-only install of BizTalk) is to select the database corresponding to
the environment you wish to administer:

Once you hit “Next”, the wizard will complete, and you will be presented
with a final confirmation dialog:

 

The VBScript as a text file is here.

How To Create Nodes from Flat Data in BizTalk Maps


It can sometimes be challenging when mapping schemas in BizTalk 2004.  One common problem is when the inbound document has one record and the source creates multiple records based on the data inside your single record.


 


The root problem arises because you have nothing to loop around in the inbound document and need to create multiple nodes on the output.



How can this be handled in the mapper?



Two ways: Functoids or XSLT Template



BizTalk 2004 introduces a new Functoid just for this situation.  It is called the Table Looping Functoid.  It is accompanied by the Table Looping Functoid Data Extractor.  The table looping functoid will take a flat row of data and produce multiple nodes of data on the destination schema.



CRITICAL: The key to working with the table looping functoid is to label your links.  This can be done by selecting the link and going to Properties.  Under General you can set the label.  This will show up inside the Input Parameters section of your functoids as the label name.



An alternative to the Table Looping Functoid is to use a custom XSLT Template call inside a scripting functoid. This requires error prone XSLT coding.



In both cases, the number of input parameters must be known ahead of time.



I have put together a sample showing both the Table Looping Functoid and XSLT Template solutions.



DOWLOAD: Sample Create Nodes in Maps


 


In addition to Node Creation, this sample includes a map called Map_RowSplit.  This sample takes an order item and evaluates the node for “Y” (meaning the item is gift wrapped).  If it is “Y” two line items are created on the output rather then one.  This uses the and XSLT element.

Creating Nodes Inside A Map

This mapping sample shows how to create repeating nodes from flat data inside the mapper.  This sample also shows the use of some custom XSLT code inside the BizTalk mapper.

This sample works with BizTalk 2004 and BizTalk 2006.

Get more information from the original blog post on this topic: https://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalk/archive/2004/10/28/how-to-create-nodes-from-flat-data-in-biztalk-maps.aspx

Using XPath Inside BizTalk Orchestrations

Working with XPath inside Orchestrations is a powerful and simple feature of BizTalk 2004.  The help guide does a good job describing the process (under Using XPath in Message Assignment).

 

 

 

I have found that the XPath queries can only be done against a Message and the results can be set to a Message, XML Document or other orchestration variables.  XPath queries can also be executed against untyped messages.  That is, a Message that is of type System.Xml.XmlDocument.

 

 

 

CRITICAL: BizTalk xpath can be used to both read values and set values inside your Message.  To set values in your message, you need to be inside a Message Construct shape.

 

 

 

Here are some of the things you can do with xpath and how to do them:

 

– Set a single values inside a Message using xpath

 

 xpath(SingleXML, “//LineTotal”) = nLineTotal;

 

 

 

– Extract a single piece of data out of a Message

 

 sCustomer = xpath(InXML,”string(//Customer)”);

 

 

 

– Extract a single node out of a large XML Document and assign it to a message or variable

 

 sXPath = System.String.Format(“//Item[{0}]”,nCount);

 xDoc = xpath(InXML, sXPath);

 

 

 

– Count the number of nodes or occurrences of something inside your message

 

 nNumberItems = System.Convert.ToInt32(xpath(InXML, “count(//Item)”));

 

 

A great resource for xpath functions and expressions is the W3Schools.

 

 

 

I have put together a sample that shows several different xpath uses inside the Orchestration.  This sample takes in an Order, calculates the total per line, sends out each line item as a single message, and sends out the whole order with an order total.  Note that the Item nodes are not updated on the Output document, only on the single documents.

 

 

 

DOWNLOAD: XPath Sample

 

 

 

The de-batching approach is based on Darren Jefford’s Blog about Manual Message Splitting.  Make sure you check it out and download his sample as well.

Accessing Message Data Inside an Orchestration using XPath

BizTalk 2004 allows simple access to data inside an Orchestration by using Xpath. This can be used to read and write data as well as total message assignment. This sample shows different ways to access data using Xpath inside the Orchestration.

This sample will work for both BizTalk 2004 and BizTalk 2006.

Get more information from the original blog post on this topic: https://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalk/archive/2004/10/25/using-xpath-inside-biztalk-orchestrations.aspx

How To Assign an InfoPath Form to a Message in BizTalk

InfoPath is something I heard a lot about several months ago, but not much since then. 



Recently, I had to set an InfoPath template to a message in BizTalk 2004.  This is something that is rather simple, as long as you know what properties you need to set. 



To set an InfoPath template for use on an outgoing message just use this code inside the Message Assignment shape.  This is set up to use an InfoPath template that has been deployment to a Sharepoint site.  Other options are a Web Server or File Location.



// This sets new Processing Instructions on the Message


OutMessage(XMLNORM.ProcessingInstructionOption) = 1;


// This assigns an InfoPath template from a Sharepoint site to the document


OutMessage(XMLNORM.ProcessingInstruction) = “”;



That’s it!  Now, if you have InfoPath installed your Xml will be assigned to that template.



For more information on InfoPath and BizTalk 2004 make sure you view the MSDN On-Demand Webcast from April 19th.

BTSInstaller "bug"

After hours of fighting it, I have concluded that deploying a solution that utilizes Roles and Party’s can’t be installed using an MSI created with the BTSInstaller.  You can use the same binding file and assemblies and use BTSDeploy and it all works fine.


I plan on posting all my deployment scripts here in the next few days as the BTSInstaller gets you about 85% there, and you’re required to script the rest.


Take a look at Scott Colestock’s blog for a different option (Nant) to the BTSInstaller.


Cheers,
Todd