Orchestration variable retriever functoid (and why you should not use it)

5 April 2009

This week I spend some time on writing a functoid that retrieves the value of a variable in an orchestration. Lets take a look on the functoid’s usage first.

Usage

This is the declaration of a string variable ‘lastName’ in a very simple test orchestration:

image

This is the expression shape where the value of that variable is set to my last name:

image

This is the map that is executed using a transform shape right after the expression shape above. The map contains the variable retriever functoid. It has one parameter that takes the name of the variable to fetch.

Please pay special attention to the icon because that bloody thing took me 50% of the development time. The result shows why I try to stay away from UI development as much as possible. :-)

image

Finally this is the Xml message returned from the orchestration via the file adapter.

image

Disadvantages

At first I was a little excited that I got this working. I did some testing with different orchestrations and it seems to work OK. After a while (and thinking this over) my excitement was tempered because I think the functoid has three big disadvantages:

  1. Although questions related to this popup regularly in the BizTalk newsgroups I could not think of any real world examples. The sample above could also be implemented by using a message assignment shape after the map. In the message assignment shape the value of the variable can be assigned using xpath, properties or distinguished fields. The only way the functoid can be useful is when you need an orchestration variable value in a map to do some processing while the actual value is not mapped to the destination schema. But then again there are other ways to implement that. (Using a helper message and a multi message map). 
  2.  The functoid code contains a considerable amount of reflection code. I didn’t do any performance tests but it is obvious that reflection comes with a cost. So in terms of performance it will probably be much better  to use alternative methods.
  3.  This is probably not supported by MS. Mainly because it uses XLANG code which is normally hidden from the developers. 

These disadvantages make me conclude that this functoid is not very useful in real world scenarios. I really want to know what others think about this. So whether you agree or don’t agree please share your thoughts on this!

The other way around

Now that I figured out a way to access a variable it is a small step to take this a little further and build a functoid that WRITES the value of a variable in an orchestration. I didn’t implement such a functoid because of above mentioned points. I also think writing, as opposed to, reading is very tricky because you need to take things like serialization and locking into account.

If your still not convinced that you should not use this you can download the functoid “dll” from here.

Installation instructions:

  • copy the .dll to the ‘Mapper Extensions’ folder which resides in the BizTalk installation folder.
  • put the .dll in the gac.
  • Open a map in Visual Studio, click right in the toolbox area and choose the functoids tab.
  • Browse the the functoid dll in the ‘Mapper Extensions’ folder to add it to the toolbox.

The source is also available here. It is build using BizTalk 2006 R2.


Message creation

13 October 2008

In March Yossi Dahan blogged about various ways to create messages from scratch in an orchestration. In his post (in the comments) he also mentioned he would be very interested in the performance characteristics.

I shared this interest with him an decided to spend some time on a small test solution to measure the performance. Because I wanted to be sure about my results (and also because this was his blog subject ;-) ) I asked the real expert (Yossi) to validate my results.

With a (little delay :-) ) Yossi posted about the results.

Thanks Yossi.


Call Rules Shape, Atomic Transactions and the Orchestration Designer

13 June 2008
One of the nice improvements in BizTalk 2006 R1 (BTS2k6R1) and higher is that you don’t need to use an atomic transaction scope around the “Call Rules” shape. I guess the reason for this is that classes used internally by the Business Rules Engine are now serializable while they were not in previous release.
 
Recently the orchestration designer in Visual Studio almost got me. I wanted to use a “Call Rules” shape en saw to my surprise that the shape was grayed out in the shape context menu. This is menu you get when you right click somewhere in the orchestration designer surface.
What was going on here? Was I wrong? Was it wishful thinking? Did this new feature only exist in my head? Do I still have to use the atomic transaction scope in my orchestrations? Because Visual Studio is always right and I’m always wrong I was about to add the scope to my orchestration.
 
Because I still felt a little bit disappointed I decided to have a quick look in the BTS2k6r1 help file. Nothing special was mentioned in the topic “How to Use the Call Rules Shape” however. Still curious I also looked at the same topic in the BTS2k6r2 help file. To my surprise the topic is updated and contains the following note:  
 
In BizTalk Server 2004, you can insert a Call Rules shape within an orchestration or a Scope shape with Transaction Type set to Atomic. In BizTalk Server 2006, you do not need to have an atomic scope to insert a Call Rules shape. You can drag a Call Rules shape into the Orchestration Design Surface from the Toolbox. However, in BizTalk Server 2006, the Call Rules menu item is disabled in the context menu if you try to insert a Call Rules shape inside an orchestration that does not have an atomic scope. This is a limitation with the BizTalk Server 2006 product.
 
So I was right! You don’t have to use an atomic transaction scope anymore. Apparently there is a bug in the orchestration designer. You can only drag a call rules shape from the toolbox to the orchestration designer surface. The same option can only be used from the context menu if you are inside a scope.
 
I really wonder what the reason for this is? Is it just a bug? And why didn’t they solve this in BTS2k6r2? And also will it be solved in the coming R3.
 
Anyway what point do I want to make here? 
  • Visual Studio is not always right. In rare cases you’re right and Visual Studio is not! :-)
  • You don’t have to use an atomic transaction scope anymore when you want to use the “Call Rules” shape.

Follow

Get every new post delivered to your Inbox.