MSMQ ActiveXFormatter, Strings and BizTalk 2006

Link. January 31, 2006. Comments [10]. Posted in: BizTalk

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!


Thursday, March 23, 2006 6:08:18 PM (SA Pacific Standard Time, UTC-05:00)
Greetings,

Any insight on how to do something similar for BTS 2004? I have several publishing apps that use the ActiveXMessageFormatter when they drop to MSMQ, and the MSMQ Adapter for BTS 2004 is choking on the messages.

Any thoughts would be greatlyh appreciated.

-Rich
Rich
Thursday, March 23, 2006 6:19:50 PM (SA Pacific Standard Time, UTC-05:00)
Rich,

If your existing application sends the messages to MSMQ as strings, then you might be able to get it done by simply telling BizTalk that the messages are encoded as UTF-16 (unicode). The FixEncoding pipeline component I published should allow you to do this fairly easily.

http://www.winterdom.com/weblog/2006/01/31/FixMessageEncodingCustomPipelineComponentSample.aspx
(retro-porting it to BTS2004 should just be a matter of recreating the VS.NET 2003 projects).
Thursday, March 23, 2006 6:32:18 PM (SA Pacific Standard Time, UTC-05:00)
THanks for teh reply,
Lookslike the project files were created in VS.NET 2005...we're still on VS.NET 2003 and I'm afraid I will lose some functionality. I opened the cs files in notepad and added them to a VS.NET 2003 project and it didn't like the Dictionary <int, string> entry.

Sorry to be a pest about this.

-Rich
Rich
Thursday, March 23, 2006 6:37:13 PM (SA Pacific Standard Time, UTC-05:00)
Hi Rich,

You're right. Just replace the Dictionary<> with a Hashtable, and add a couple of casts. If you get into trouble, let me know and I'll port it back.
Friday, March 24, 2006 10:03:00 AM (SA Pacific Standard Time, UTC-05:00)
OK, I'm an idiot...

I'm a VB guy and I've never looped back to learn enough about C#. If you have the time, I'd definitely appreciate any assistance.

Thanks again,
-Rich
Rich
Wednesday, April 12, 2006 4:08:02 PM (SA Pacific Standard Time, UTC-05:00)
HELP: We need this setting on the MSMQT send adapter as well.
Don't tell me they forgot that one?!
Could you tell me where they did hide this?
I can't find the property here ms-help://MS.BTS.2006/BTS06Operations/html/d51575f6-5e01-436c-bf69-f6f1f12f125c.htm neither.
Berre
Wednesday, April 12, 2006 11:38:07 PM (SA Pacific Standard Time, UTC-05:00)
Berre,

AFAIK, they were not added. That said, it is not surprising, as as I understand it, MSMQT is not the recommended MSMQ interaction tool anymore, but rather they recommend you use the regular MSMQ adapter.

Is there any reason you prefer to use the MSMQT adapter over MSMQ?
Tuesday, April 17, 2007 11:13:20 AM (SA Pacific Standard Time, UTC-05:00)
Hey Tomas,

Been awhile...but I'm back ;)

I'm upgraading my environment to BTS2006 and I'm trying to use the FixEncoding component and I have set the Encoding proprty to 'Unicode', as the applications that send teh XML are still using the AxtiveXMessageFormatter. I had this working fine in BTS2004 with the ported version, but after downloading and installing the 2006 version of your component, I'm back to getting errors saying "No Disassemble stage components can recognize teh data".

Obviously I'm missing something, but I'm unsure what to check as I compare my BTS2004 and BTS2006 setup, and they are identical.

Can you help me again?
-Rich
Tuesday, April 17, 2007 11:34:32 AM (SA Pacific Standard Time, UTC-05:00)
Grr..never mind, I figured it out...thanks again, sir!
Wednesday, May 09, 2007 5:19:19 PM (SA Pacific Standard Time, UTC-05:00)
Hi Rich,
I am having the same problem. I am getting the error "No Disassemble stage components can recognize the data". Mine is BTS 2006 as well. Please help!!
sharmila
Comments are closed.

About

Tomas Restrepo is co-founder of devdeo ltda. His interests include .NET, Connected Systems, PowerShell and, lately, dynamic programming languages. More...

email: tomas@winterdom.com
msn: tomasr@passport.com
twitter: tomas_restrepo

Technorati Profile

devdeo logo

View my profile on LinkedIn

MVP logo

Syndicate

Ads

Links

Tag Cloud

.NET (232) Architecture (47) ASP.NET (6) BizTalk (170) Blogging (64) C++ (3) Castle (2) Commerce Server (3) Development (118) DLR (7) Enterprise Services (25) Fonts (4) Host Integration Server (1) LINQ (3) Linux (5) NHibernate (1) Personal (143) PowerShell (22) QuickCounters (4) Tools (74) Vista (38) VS Color Scheme (10) VSTO (2) WCF (64) Web Services (87) WinFX (80) Workflow (47) WPF (5) XML (21)

Statistics

Total Posts: 986
This Year: 56
This Month: 6
This Week: 0
Comments: 755

Blogroll

Post Archive

Other

Copyright © 2002-2008, Tomas Restrepo.

Powered by: newtelligence dasBlog 1.9.7174.0

Sign In