I had forgotten completely to blog about this, but was just reminded by an email from Doug Girard regarding something I had written some time ago on the BizTalk 2006 beta newsgroups.

The MSMQ Adapter in BizTalk 2006 now supports a new property, BodyType (MSMQ.BodyType), which maps to the PROPID_M_BODY_TYPE message property in MSMQ. The cool thing about this is that it makes it much easier for BizTalk to send messages to old Win32/COM applications that used the MSMQ COM formatting, and .NET Applications that used the ActiveXMessageFormatter to read the messages.

In BizTalk 2004, this usually requiered changing the destination application, so that instead of using a formatter, it read the BodyStream of the message directly using a known encoding. For obvious reasons this is undesirable. The reason why this was necessary is that the ActiveXMessageFormatter (as the old COM rules) relies on the presence of the PROPID_M_BODY_TYPE property in the message in order to figure out how to interpret the message contents. Since the BizTalk Server 2004 MSMQ/MSMQT adapters never filled in that property, the formatter would always throw an exception when you tried to read the message body.

With BizTalk 2006, it is now very easy to achieve this without modifying the code, since using the new MSMQ.BodyType property you can now get this field to match what your code expects. The value of the MSMQ.BodyType property is an integer corresponding to one of the VT_XXX variant types, such as VT_I4 for Int32, or VT_BSTR for a string.

For example, if your existing .NET application expects the message contents to be a string, then you can now just configure the MSMQ adapter properties on your BizTalk Send Port to set MSMQ.BodyType to the value 8 (VT_BSTR), and then configure a send pipeline to write your message in Unicode (with no BOM) encoding and it will be processed correctly!


Tomas Restrepo

Software developer located in Colombia.