|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Read Messages : Just how so? |
« View previous topic :: View next topic » |
Author |
Message
|
major7 |
Posted: Mon Jun 30, 2008 6:20 am Post subject: Read Messages : Just how so? |
|
|
Novice
Joined: 26 Jun 2008 Posts: 12
|
Hi all,
I managed to connect to MQ using XMS.Net, finally! now that i walk through the queue using a browser, what I need is the content of the messages.
I get headers (JMS Headers as well as userdefined ones!), and most of the messages are of type "XMS_MESSAGE_TYPE_BYTES". Some obiviously are XMS_MESSAGE_TYPE_STREAM. Depending on their type, I cast the messages.
Code: |
foreach(IMessage message in errors)
{
Console.WriteLine(message);
if (message is IBytesMessage)
{
IBytesMessage msg = (IBytesMessage)message;
[...]
}
else if (message is IStreamMessage)
{
IStreamMessage msg = (IStreamMessage)message;
[...]
}
}
|
What I want to do now is get the body of the messages, but I don't know how to. Could anyone help me with that? I tried ReadBytes, but that wouldn't work...
Thanks a lot in advance,
Sebi |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Jun 30, 2008 7:06 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you looked at one of the multiple JMS tutorials on the Web? This should certainly give you the guidelines.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
major7 |
Posted: Tue Jul 01, 2008 12:05 am Post subject: |
|
|
Novice
Joined: 26 Jun 2008 Posts: 12
|
seems like everybody knows that stuff already. anyway, here's how i solved it :
Code: |
foreach(IMessage message in errors)
{
if (message is IBytesMessage)
{
IBytesMessage msg = (IBytesMessage)message;
Byte[] buffer = new byte[msg.BodyLength];
msg.ReadBytes(buffer);
String content = Encoding.UTF8.GetString(buffer);
}
else if (message is IStreamMessage)
{
IStreamMessage msg = (IStreamMessage)message;
Object c = msg.ReadObject();
byte[] buffer = (byte[])c;
String content = Encoding.UTF8.GetString(buffer);
}
} |
maybe somebody can save time and trouble using this. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|