Monday, February 27, 2006

One or more instances of the orchestration still exist

Lately I tried to redeploy a BizTalk 2006 solution from Visual Studio 2005. Unfortunately I was confronted with the following error message “Could not change the bindings for orchestration '.', Version=1.0.0.0,Culture=neutral, PublicKeyToken=c380e04620d206e8' as one or more instances of the orchestration still exist”.
When I tried to Unenlist and delete the Orchestration from the BizTalk Administration tool, I received the same error.

I found out that I had a few suspended instances. These instances need to be terminated before you can undeploy/redeploy the orchestration.

Terminating instances can be done in several manners:
- the polite manner: by terminating the instances using the BizTalk Administration Tool
- the not so polite manner: by using a Stored Procedure to clean up the MessageBox

Removing instances using the BizTalk Administration Tool
In the BizTalk Administration Group click in the left pane on ‘BizTalk Group [Name of Computer/Name of Management database]’. In the right pane the ‘Group Overview’ appears. Click on the tab page ‘New query’ to create a query that searches for the suspended instances. In the ‘Query Expression’ grid the first Search field is already selected, namely ‘Search For’, also the ‘Equals’ operator is already filled in in the second field. All we have to do in the ‘Value’-field is search for suspended instances. And… lucky us: when we open the dropdown box we see that ‘Suspended Service Instances’ is one of the values we can choose! Next, we run the query by hitting the button with the label 'Run Query'. The grid ‘Query results’ now contains all suspended instances found. All we need to do is select all suspended instances, right click on the selection and choose ‘Terminate Instances’. The BizTalk Administration Tool asks for confirmation and removes the instances. When you rerun the query, the instances will be removed and the orchestration can be undeployed/redeployed. So far for the polite manner.

Removing instances using a Stored Procedure
The less polite manner to remove suspended instances is by running a Stored Procedure which will clean up the MessageBox. Attention: this is NOT a recommended procedure on production environments!
Open the SQL Server Management Studio and connect to the database server. In the left pane expand the server-node and the Databases-node. Next, click on the MessageBox-database (BizTalkMsgDb) and hit the ‘New Query’-button in the toolbar. In the right pane you can enter SQL commands. Since you selected the MessageBox-database in the left pane, the commands are executed against that database. Now type: 'exec bts_CleanupMsgbox 0' (without the quotes) and hit the ‘! Execute’-button in the toolbar. All suspended instances will now be removed. You can now undeploy/redeploy the orchestration.

New contributor on board

Hi all,

My name is Lex Hegt and from now on I will try to do regular postings on this blog as well. Just like Isaac and Randal I work for The Vision Web. On this blog I want to document/share problems and solutions I run into.

Please feel free to react on my postings!

Lex

Wednesday, February 08, 2006

XSLT performance when mapping large documents in BizTalk

Recently I had to map a document with many thousand rows. I could not split the document because before I could split it, the document’s nodes had to be sorted.

With such large files you generally test it using a small subset to avoid waiting for maps to complete, I built an XSLT which worked great, I thought.

When you use a select filter such as "not(KeyValue=preceding-sibling::row/ KeyValue)" you end up with a huge performance hit the larger the document gets. My map went from 2 seconds for 50 rows to 10 minutes for a few thousand.

How to improve performance when you have large XML files to map that you can’t split? Try using xsl:key instead, which builds an index of keys from which you can much more efficiently select.

Here is a sample XSLT that demonstrates how to use the xsl:key:


<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:ns0="http://Conversion.schemas">

    <xsl:output method="xml" indent="no" />

    <xsl:key name="NumberKey" match="/*[local-name()='top' and namespace-uri()='http://biztalk/Conversion.schemas']/*[local-name()='row' and namespace-uri()='']"

        use="keyValue" />

    <xsl:template match="/">

        <ns0:Rows>

            <xsl:for-each select="/*[local-name()='top' and namespace-uri()='http://biztalk/Conversion.schemas']/*[local-name()='row' and namespace-uri()='' and generate-id(.) = generate-id(key('NumberKey', keyValue)[1])]">

                <xsl:variable name="current_Number" select="keyValue" />

                <Data>

                    <keyValue>

                        <xsl:value-of select="$current_Number" />

                    </keyValue>

                    <xsl:for-each select="//row[keyValue=$current_Number]">

                        <Part>

                            <PartID>

                                <xsl:value-of select="nr_data" />

                            </PartID>

                        </Part>

                    </xsl:for-each>

                </Data>

            </xsl:for-each>

        </ns0:Rows>

    </xsl:template>

</xsl:stylesheet>