4 Replies Latest reply on Sep 14, 2011 7:49 PM by 886634

    Serializing & Deserializing objects through ObjectMessage


      I'm having trouble sending objects/instances of a class (Data) through the message queue. I also made Data to be serializable.
      public class Data implements Serializable {
      The following are snippets of code from the Message producer side:
      objectMessage = mySess.createObjectMessage();
      MessageProducer myMsgProducer = mySess.createProducer(myQueue);
      Data e = new Data();
      And the following are snippets of code from the message consumer:
      public void onMessage(Message message) {
                   if(message instanceof ObjectMessage ){
                    ObjectMessage objMsg = (ObjectMessage) message;
                    Data myData = (Data)objMsg.getObject();
               catch(JMSException e){
                    System.out.println("Exception occured: " + e.toString());
      The result of attempting to cast the objMsg to a Data is an exception thrown.

      i did noticed however, that when I was debugging the message consumer, that the byteArrayInputStream values for both message and objMsg are null meaning that the data is not being sent or received. Any help would be greatly appreciated, thanks!

      Edited by: 883631 on Sep 13, 2011 4:09 PM

      Edited by: EJP on 14/09/2011 09:22: added {noformat}
      {noformat} tags. Please use them.