ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Read Messages : Just how so?

Post new topic  Reply to topic
 Read Messages : Just how so? « View previous topic :: View next topic » 
Author Message
major7
PostPosted: Mon Jun 30, 2008 6:20 am    Post subject: Read Messages : Just how so? Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Mon Jun 30, 2008 7:06 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
major7
PostPosted: Tue Jul 01, 2008 12:05 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Read Messages : Just how so?
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.