ActiveXMessageFormatter Rocks!

Recently I was asked to send an MSMQ message which only contained the data from a flat file. The reason for this was the need to simply relay messages that came in through MSMQ onto a distant trading partner using MQSeries. Through BizTalk this is made possible through send port filters which can essentially query messages coming into the BizTalk MessageBox database through receive locations and then forward them onto the send ports based on the filters. So in this scenario the goal was to reduce latency as much as possible by simply forwarding the message received through BizTalk to the distant partner. The challenge is in getting the format of the MSMQ message body to simply be the flat file string.
 
Sending text for an MSMQ message body using the .NET namespace System.Messaging will by default use the XmlMessageFormatter in the body of the message. Switching over to the BinaryMessageFormatter will almost accomplish this goal but you will see some extra characters in the body if you look at the body contents as shown here for an MSMQ message (the desired message does not begin until the 0120 on the fourth line):
 
MSMQMEssageHeader 
 
One formatter that accomplishes these objectives but does receive much written about it is the ActiveXMessageFormatter (in System.Messaging), which will serialize a string exactly like you would expect it to w/o any additional header or wrapping content. This is very useful when you want to send something across to MSMQ without any extra wrapping or header content.
 
 
Advertisements

  1. #1 by Ben on May 27, 2008 - 7:14 pm

    A related thing to be aware of is that .NET by default uses UTF-16 encoded strings so an application cannot read the UTF-16 string in the body of an MSMQ message, you will need to encode it differently (such as in ASCII) via a MemoryStream.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: