Problem with format of msmq messages, .net

P

Peter Hurford

Hi,

First time using msmq in .net environment and I think I am missing
something obvious.

I am using the System.Messaging classes Message & MessageQueue to send
a message.

I want to send a plain-text message (e.g. "Test"), but by default the
Message class serializes it to xml (e.g. "<string>Test</string>"). This
is a problem for me, as the application which will be picking messages
off the queue is a third-party application which requires messages in a
specific format. I have no flexibility to change this.

I've looked briefly at IMessageFormatter, but surely I don't have to
write my own formatter to send *plain-text* messages? I've looked at
BodyStream, but again, surely I don't have to mangle my string into a
byte array simply to send it down the line?

Or do I? Any pointers?

TIA,
Pete
 
Y

Yves. L.

Hi peter.

You could try the BinaryMessageFormatter .
If it does not work as you want , I'm afraid , you'll have to write your
own IFormater

YvesL
 
P

Peter Hurford

I did look at BinaryMessageFormatter but it basically just serializes
to something slightly different to the Xml formatter. The real problem
was that the Message class attempted to serialize at all.

I suppose if I were using the Message class to pick up the message too,
I probably wouldn't even notice this serialization taking place. But as
I said, this message is going to a third-party app so the body of the
message needed to be "just so".

In fact the 3rd-party app is a bit of middleware, like Biztalk but not
Biztalk. It is looking for xml, e.g. "<a>b</a>". The Message class
serialized this to "<string>&lt;a&gt;b etc. etc." which as you would
imagine got bounced by the 3rd party app's parser.

Dejan's suggestion did the trick, however - setting BodyStream instead
prevents serialization from taking place.

Thanks for your response, though. Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top