title: How to get the underlying object from a SpyMessage in JBossMQ
body: <p>I am trying to write a simple Java program that reads from JBossMQ's jms_messages table using JDBC. I am using JBoss 4.0.4.GA.</p>
  
  <p>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).</p>
  
  <p>I have a result set "rs" from this statement:</p>
  
  <pre><code>SELECT messageid, messageblob FROM jms_messages WHERE DESTINATION LIKE 'TOPIC.MyTopic%' limit 3"
  </code></pre>
  
  <p>and then I do this (based on JBoss code):</p>
  
  <pre><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);
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>I've tried asking this question on the JBoss forum without reply, so I'm hoping for better luck here.</p>
  
  <p>Thanks.</p>