MSMQ reading message

B

Bob Clegg

Hi,
First venture into using MSMQ
Prog A owns queue and is receiving.
Prog B detects queue and sends message

Prog B appears to be working in that I can see the messages being created in
the Message console.
Prog A detects the message but I cannot get it to deserialise it.
It errors with 'Can't deserialise unknown format ' or words to that effect.
I just want to send the string "E".
In the message write I started simple with
myQue.send("E")
That didn't work so I went
to using an ActiveXFormatter to send and receive.
Result is still the same.
The help file indicates that you should be able to simply treat the body
like a string but my attempts to coerce it into a string have failed.
Any help on this would be appreciated.
Current code snippets follows.
Thanks
Bob

ProgA (RECEIVER)
Static qe As MessageEnumerator = q.GetMessageEnumerator

Dim msg As Message

qe.MoveNext()

Dim f As New System.Messaging.ActiveXMessageFormatter

Dim m As Object

msg = qe.RemoveCurrent

m = f.Read(msg)



ProgB (TRANSMITTER)

Dim mq As MessageQueue

Dim m As Message

m = New Message

Dim strMessage As String = "E"

Dim f As New System.Messaging.ActiveXMessageFormatter

f.Write(m, strMessage)

For Each mq In mqEvents

mq.Send(m)

Next
 
P

Peter Huang

Hi Bob,

I can not reproduce the problem with your code.
Based on my experience, the problem may be caused by received another
message in the message queue which is not the ActiveXFormatter, so the
error occur.

So I suggest you clear the messagequeue first and then use the code send a
message to the emply message and then stop the appliation, now we monitor
the message queue in the mmc console there should be one messge in the
queue.

Now we run the receiving application to receive the messge to see if we can
received the message and deserialize the content. Also now the messge queue
should has been emptied because we have called the removecurrent.

Here is a KB for your reference.
HOW TO: Write to and Read from Microsoft Message Queue Server in Visual
Basic .NET (315698)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;315698

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

bclegg

Hi Peter,
Thanks for your reply,
All is working now.
I have moved to using the XMLFormatter as per 'receiving messages
asynchronously'
regards
Bob
 

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