Pages

Sending text for an MSMQ message body using the .NET namespace System.Messaging XmlMessageFormatter to BizTalk || Use of ActiveXMessageFormatter

Friday, September 30, 2011
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):




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.

No comments:

Post a Comment

Post Your Comment...