0 Replies Latest reply on Mar 2, 2013 12:24 PM by petal1

    Can get SpyMessage when reading from jms_messages, but how do I get the actual message content?

    petal1 Newbie



      I am trying to write a simple Java program that reads from jms_messages using JDBC.I am using JBoss 4.0.4.GA.


      I can get the as far as getting a SpyMessage, but how can I get the actual message content (which is an Object in the particular case I'm looking at).


      I have a result set rs from this statement:


          SELECT messageid, messageblob FROM jms_messages WHERE DESTINATION LIKE 'TOPIC.MyTopic%' limit 3"


      and then I do this (copied from JBoss code):


          long messageid = rs.getLong(1);

          SpyMessage message = null;

          byte[] st = rs.getBytes(2);

          ByteArrayInputStream baip = new ByteArrayInputStream(st);

          ObjectInputStream ois = new ObjectInputStream(baip);


          message = SpyMessage.readMessage(ois);

          message.header.messageId = messageid;


          String jmstype = message.getJMSType();

          String jms_message_id = message.getJMSMessageID();

          System.out.println("jmstype=" +jmstype);

          System.out.println("jms_message_id=" +jms_message_id);


          String propertyName;

          Enumeration e = message.getPropertyNames();

          while (e.hasMoreElements())


              propertyName = (String)e.nextElement();

              System.out.println("property name = " +propertyName);



      but I get no properties printed and I don't know how to get my actual object from the SpyMessage (actually a SpyObjectMessage). I'd be grateful for any pointers.