How to handle Zombie

I’m glad to present the first release of BizTalk Zombie Management. You can find it at http://btszombiemanagement.codeplex.com/

What is BizTalk Zombie Management ?

This is a codeplex project. It proposes a solution to process zombie message after their zombified state. It’s a windows service that need to be install on each BizTalk machine.
When a zombie is raised, the service catch it and retrieve back the message. Next the message is published for a BizTalk adapter.

Here is the process flow :

When use BizTalk Zombie Management ?

A zombie message is a message that was routed to a running orchestration from the messagebox and was « in flight » when the orchestration ended. An « in flight » message is a message that has been routed to a service instance and so is in a messagebox queue destined for the service instance. Since the message can no longer be consumed by the subscribing orchestration instance, the message is suspended and marked with a ServiceInstance/State value of « Suspended (Non-resumable) ».

A zombie service instance is an instance of an orchestration which has completed while a message that was routed to the orchestration instance from the messagebox was still « in flight ». Since the orchestration instance has ended, it cannot consume the « in flight » messages and so is suspended and marked with a ServiceInstance/State value of « Suspended (Non-resumable) ».

The occurrence of zombies typically falls into one of the following categories:

Terminate control messages – The orchestration engine allows the use of control messages to cancel all currently running work in a specific orchestration instance. Since the control message immediately halts the running orchestration, zombie instances are not unexpected. A number of Human Workflow related designs tend to use this mechanism as well as some other designs.

Parallel listen receives – In this scenario the service instance waits for 1 of n messages and when it receives certain messages it does some work and terminates. If messages are received on a parallel branch just as the service instance is terminating, zombies are created.

Sequential convoys with non-deterministic endpoints – In this scenario, a master orchestration schedule is designed to handle all messages of a certain type in order to meet some type of system design requirement. These design requirements may include ordered delivery, resource dispenser, and batching. For this scenario, the tendency is to define a while loop surrounding a listen with one branch having a receive and the other having a delay shape followed by some construct which sets some variable to indicate that the while loop should stop. This is non-deterministic since the delay could be triggered, but a message could still be delivered. Non-deterministic endpoints like this are prone to generating zombies.

(source : MSDN)

The service cover all case which generate zombie. Warning, this service does not prevent Zombie generation. It only provide a way to avoid loosing data

How does it work ?

BizTalk Zombie Management is C# service which keep an eye on BizTalk WMI table. When a zombie occur a special BizTalk event is generated and catched for processing.

For more information go to the documentation page :  http://btszombiemanagement.codeplex.com/documentation

Persistence points, tired to repeat it

Often ignored, but a really important, persistence points in Biztalk are the key issue in dealing with Orchestration Performance. Many applicative problem come from a misunderstanding of this concept.

Sandro perreira (a great biztalk MVP) wrote a great article about it : http://sandroaspbiztalkblog.wordpress.com/2009/10/23/biztalk-orchestration-%E2%80%93-understanding-persistence-points/

You should read it,

All BizTalk developper must be careful to those concepts and organize their developpement around it.

A common mistake is the send port in a while shape, more than 50 send don’t forget to use atomic scope.

Another one, be careful with custom c# object and the serialization way.

Really interesting.

Xpath function key

Xpath is a powerfull tool but we use only small part of it(me the first). Everybody use string or count function but more function exist

Xpath query

Before introducing function, let’s talk about Xpath query.

To build Xpath query you need to respect this protocol :

Expression Description
nodename Selects all child nodes of the named node
/ Selects from the root node
// Selects nodes in the document from the current node that match the selection no matter where they are
. Selects the current node
.. Selects the parent of the current node
@ Selects attributes

You can find sample by openning a map. For getting your own query easily, open your schema in Visual Studio, select the choosen node. On the property Tab you’ve got a field Instance Xpath :

Here is a summary (you can found all function on the MSDN : http://msdn.microsoft.com/en-us/library/ms256138.aspx)

Node-Set Functions

Function Description
count Returns the number of nodes in the node-setargument.
id Selects elements by their unique ID.
last Returns a number equal to context size of the expression evaluation context.
local-name Returns the local part of the expanded name of the node in the node-setargument that is first in document order.
name Returns a string containing a QName representing the expanded name of the node in the node-set argument that is first in document order.
namespace-uri Returns the namespace Uniform Resource Identifier (URI) of the expanded name of the node in the node-set argument that is first in document order.
position Returns the index number of the node within the parent.

 

Note : Some function are unusable in an orchestration : id, last, position

String Functions

Function Description
concat Returns the concatenation of the arguments.
contains Returns true if the first argument string contains the second argument string; otherwise returns false.
normalize-space Returns the argument string with the white space stripped.
starts-with Returns true if the first argument string starts with the second argument string; otherwise returns false.
string Converts an object to a string.
string-length Returns the number of characters in the string.
substring Returns the substring of the first argument starting at the position specified in the second argument and the length specified in the third argument.
substring-after Returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string.
substring-before Returns the substring of the first argument string that precedes the first occurrence of the second argument string in the first argument string.
translate Returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string.

Boolean Functions

Function Description
boolean Converts the argument to a Boolean.
false Returns false.
lang Returns true if the xml:lang attribute of the context node is the same as the argument string.
not Returns true if the argument is false, otherwise, false.
true Returns true.

Number Functions

ceiling Returns the smallest integer that is not less than the argument.
floor Returns the largest integer that is not greater than the argument.
number Converts the argument to a number.
round Returns an integer closest in value to the argument.
sum Returns the sum of all nodes in the node-set. Each node is first converted to a number value before summing.

Microsoft XPath Extension Functions

XPath Extension Functions for XSD Support

Function Description
ms:type-is Compares the current node’s data type against the specified node type.
ms:type-local-name ([node-set]) Returns the nonqualified name of the XSD type of the current node or the first node (in document order) in the provided node-set.
ms:type-namespace-uri ([node-set]) Returns the namespace URI associated with the XSD type of a current node or the first node (in document order) in the provided node-set.
ms:schema-info-available Returns true if XSD information is available for a current node.

XPath Extension Functions of Miscellaneous Utilities

Function Description
ms:string-compare Performs lexicographical string comparison.
ms:utc Converts the prefixed date/time related values into Coordinated Universal Time and into a fixed (normalized) representation that can be sorted and compared lexicographically.
ms:namespace-uri Resolves the prefix part of a qualified name into a namespace URI.
ms:local-name Returns the local name part of a qualified name by stripping out the namespace prefix.
ms:number Takes a string argument in XSD format and converts it into an XPath number.
ms:format-date Converts standard XSD date formats to characters suitable for output.
ms:format-time Converts standard XSD time formats to characters suitable for output.

How to Debatch into an orchestration with a pipeline

This is a frequent problem, and many solutions exist. But I will explain the solution with a pipeline which is more effecient than the solution with xpath solution

Here is my case, I receive data from Oracle DataBase with WCF-Oracle adapter and I need to process line per line.

WCF-Oracle work in my case in Receive-Response behavior so I need to develop an orchestration and debatch within. Lire la suite