<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: 3 ways of programmatically extracting a message body from the BizTalk tracking database</title>
	<atom:link href="http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/</link>
	<description>Connected systems and the occasional picture</description>
	<lastBuildDate>Mon, 16 Nov 2009 07:37:18 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: 3 ways of programmatically extracting a message body from the BizTalk tracking database - Claudio Santorum Blog</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-348</link>
		<dc:creator>3 ways of programmatically extracting a message body from the BizTalk tracking database - Claudio Santorum Blog</dc:creator>
		<pubDate>Thu, 14 May 2009 13:16:13 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-348</guid>
		<description>[...] qui [...]</description>
		<content:encoded><![CDATA[<p>[...] qui [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thiago Almeida</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-257</link>
		<dc:creator>Thiago Almeida</dc:creator>
		<pubDate>Tue, 09 Dec 2008 20:05:47 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-257</guid>
		<description>There&#039;s probably a better way of finding out which tracking spool table holds your message. But one way is to call loadtrackedmessagecontext twice, first passing 1 as the spool id and then 2 as the spool id. Of course you only need to call the second one if the first one didn&#039;t find it.</description>
		<content:encoded><![CDATA[<p>There&#8217;s probably a better way of finding out which tracking spool table holds your message. But one way is to call loadtrackedmessagecontext twice, first passing 1 as the spool id and then 2 as the spool id. Of course you only need to call the second one if the first one didn&#8217;t find it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Jansson</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-256</link>
		<dc:creator>Daniel Jansson</dc:creator>
		<pubDate>Tue, 09 Dec 2008 15:08:11 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-256</guid>
		<description>Thank you Alister, great example. Works like a charm.
However, the loadtrackedmessagecontext procedure requires the spool as input, is there
a good way to retrieve this?</description>
		<content:encoded><![CDATA[<p>Thank you Alister, great example. Works like a charm.<br />
However, the loadtrackedmessagecontext procedure requires the spool as input, is there<br />
a good way to retrieve this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thiago Almeida</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-228</link>
		<dc:creator>Thiago Almeida</dc:creator>
		<pubDate>Tue, 28 Oct 2008 04:27:20 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-228</guid>
		<description>Nice Alister, great work on the Reflector, thanks for sharing!</description>
		<content:encoded><![CDATA[<p>Nice Alister, great work on the Reflector, thanks for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alister</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-226</link>
		<dc:creator>Alister</dc:creator>
		<pubDate>Mon, 27 Oct 2008 14:38:38 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-226</guid>
		<description>Regarding the message context, it is actually possible to get this from the database.  I&#039;ve never found it documented anywhere, but by working back through the BizTalk code using Reflector I was able to figure it out:

First add references to Microsoft.BizTalk.Interop.Agent.dll and Microsoft.BizTalk.Pipeline.dll and use the following namespaces:

using Microsoft.BizTalk.Agent.Interop;
using Microsoft.BizTalk.Component.Interop;
using Microsoft.BizTalk.Message.Interop;

Then call the stored proc ops_LoadTrackedMessageContext and then get the result into a MemoryStream as in the code above.

You can then walk through the context as follows:

MemoryStream stream = ... // result of calling ops_LoadTrackedMessageContext
IBaseMessageContext context = ((IBTMessageAgentFactory)((IBTMessageAgent)new BTMessageAgent())).CreateMessageContext();
((IPersistStream)context).Load(stream);
for (int i = 0; i &lt; context.CountProperties; ++i)
{
    string propName;
    string propNamespace;
    object propValue = context.ReadAt(i, out propName, out propNamespace);
    System.Console.Out.WriteLine(propNamespace + &quot;, &quot; + propName + &quot;: &quot; + propValue.ToString());
}</description>
		<content:encoded><![CDATA[<p>Regarding the message context, it is actually possible to get this from the database.  I&#8217;ve never found it documented anywhere, but by working back through the BizTalk code using Reflector I was able to figure it out:</p>
<p>First add references to Microsoft.BizTalk.Interop.Agent.dll and Microsoft.BizTalk.Pipeline.dll and use the following namespaces:</p>
<p>using Microsoft.BizTalk.Agent.Interop;<br />
using Microsoft.BizTalk.Component.Interop;<br />
using Microsoft.BizTalk.Message.Interop;</p>
<p>Then call the stored proc ops_LoadTrackedMessageContext and then get the result into a MemoryStream as in the code above.</p>
<p>You can then walk through the context as follows:</p>
<p>MemoryStream stream = &#8230; // result of calling ops_LoadTrackedMessageContext<br />
IBaseMessageContext context = ((IBTMessageAgentFactory)((IBTMessageAgent)new BTMessageAgent())).CreateMessageContext();<br />
((IPersistStream)context).Load(stream);<br />
for (int i = 0; i &lt; context.CountProperties; ++i)<br />
{<br />
    string propName;<br />
    string propNamespace;<br />
    object propValue = context.ReadAt(i, out propName, out propNamespace);<br />
    System.Console.Out.WriteLine(propNamespace + &#8220;, &#8221; + propName + &#8220;: &#8221; + propValue.ToString());<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thiago Almeida</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-179</link>
		<dc:creator>Thiago Almeida</dc:creator>
		<pubDate>Fri, 03 Oct 2008 00:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-179</guid>
		<description>Hi Daniel,
I&#039;ve investigated this further (and noticed your post on the forum!). It indeed doesn&#039;t release the connections straight away. I does release all of them when you close the application though.
It eventually releases them however: I tested calling it 226 times to save all the tracked messages I had on my deve machine. It took about 11 minutes to release all the connections if I left the application open. 
Calling dta.Dispose() for the TrackingDatabase passed to the GetTrackedMessage method does not help, and even refactoring BizTalkOperations to get access to the OperationsGroup object exposed by the private _biztalkGroup property then calling it&#039;s dispose method does not release them.
You might have to either rely on the connections getting slowly released or the &quot;create an app domain&quot; method you described on the forums post.</description>
		<content:encoded><![CDATA[<p>Hi Daniel,<br />
I&#8217;ve investigated this further (and noticed your post on the forum!). It indeed doesn&#8217;t release the connections straight away. I does release all of them when you close the application though.<br />
It eventually releases them however: I tested calling it 226 times to save all the tracked messages I had on my deve machine. It took about 11 minutes to release all the connections if I left the application open.<br />
Calling dta.Dispose() for the TrackingDatabase passed to the GetTrackedMessage method does not help, and even refactoring BizTalkOperations to get access to the OperationsGroup object exposed by the private _biztalkGroup property then calling it&#8217;s dispose method does not release them.<br />
You might have to either rely on the connections getting slowly released or the &#8220;create an app domain&#8221; method you described on the forums post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thiago Almeida</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-177</link>
		<dc:creator>Thiago Almeida</dc:creator>
		<pubDate>Thu, 02 Oct 2008 10:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-177</guid>
		<description>Daniel,

I&#039;m not sure you will be able to get the message context using the third method. See the &quot;What used to be the problem?&quot; section of Richard&#039;s post here: http://www.richardhallgren.com/reading-the-message-body-and-context-from-the-biztalkdtadb-using-operations-library-in-biztalk-2006/

I suppose to release the connection to the tracking database you would have to dispose of the BizTalkOperations  or the TrackingDatabase object - I will investigate some more tomorrow. This issue has been found before with not many comments http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3896987&amp;SiteID=17 so it might be worth spending some time on it!

Regards, Thiago</description>
		<content:encoded><![CDATA[<p>Daniel,</p>
<p>I&#8217;m not sure you will be able to get the message context using the third method. See the &#8220;What used to be the problem?&#8221; section of Richard&#8217;s post here: <a href="http://www.richardhallgren.com/reading-the-message-body-and-context-from-the-biztalkdtadb-using-operations-library-in-biztalk-2006/" rel="nofollow">http://www.richardhallgren.com/reading-the-message-body-and-context-from-the-biztalkdtadb-using-operations-library-in-biztalk-2006/</a></p>
<p>I suppose to release the connection to the tracking database you would have to dispose of the BizTalkOperations  or the TrackingDatabase object &#8211; I will investigate some more tomorrow. This issue has been found before with not many comments <a href="http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3896987&amp;SiteID=17" rel="nofollow">http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3896987&amp;SiteID=17</a> so it might be worth spending some time on it!</p>
<p>Regards, Thiago</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fat64</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-176</link>
		<dc:creator>Fat64</dc:creator>
		<pubDate>Thu, 02 Oct 2008 09:48:57 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-176</guid>
		<description>You are partially right. I had Biztalk Server 2006, not R2. With R2 it works fine. Thank you!</description>
		<content:encoded><![CDATA[<p>You are partially right. I had Biztalk Server 2006, not R2. With R2 it works fine. Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Jansson</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-175</link>
		<dc:creator>Daniel Jansson</dc:creator>
		<pubDate>Thu, 02 Oct 2008 09:25:29 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-175</guid>
		<description>Another question ;)
Does anyone know how to retrieve the message property bag / context using the last example?
The message body works fine, and I assume the context is in the imgPropBag field. 
But I get exceptions when trying to decompress that.</description>
		<content:encoded><![CDATA[<p>Another question <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Does anyone know how to retrieve the message property bag / context using the last example?<br />
The message body works fine, and I assume the context is in the imgPropBag field.<br />
But I get exceptions when trying to decompress that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Jansson</title>
		<link>http://connectedthoughts.wordpress.com/2008/04/02/3-ways-of-programatically-extracting-a-message-body-from-the-biztalk-tracking-database/#comment-174</link>
		<dc:creator>Daniel Jansson</dc:creator>
		<pubDate>Thu, 02 Oct 2008 08:01:31 +0000</pubDate>
		<guid isPermaLink="false">http://connectedthoughts.wordpress.com/?p=28#comment-174</guid>
		<description>I&#039;ve found some problems using two of the methods:

1. Using the operation dll:s, sql connections used are not closed when message has been received. If you for instance invokes the gettrackedmessage 1000 times in a row, you will have 1000 open sql connections until the application is closed.

2. Using WMI to retrieve the message, you will have problem in a clustered environment if you try to receive messages sometimes. Out of 1000 messages, only a few percent is retrieved correctly.

Any solutions to the two problems?</description>
		<content:encoded><![CDATA[<p>I&#8217;ve found some problems using two of the methods:</p>
<p>1. Using the operation dll:s, sql connections used are not closed when message has been received. If you for instance invokes the gettrackedmessage 1000 times in a row, you will have 1000 open sql connections until the application is closed.</p>
<p>2. Using WMI to retrieve the message, you will have problem in a clustered environment if you try to receive messages sometimes. Out of 1000 messages, only a few percent is retrieved correctly.</p>
<p>Any solutions to the two problems?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
