2 Replies Latest reply on May 24, 2007 4:35 PM by Len DiMaggio

    Reading a TextMessage from a queue?

    Len DiMaggio Apprentice

      Working with ESB MR2 - I'm having a problem getting a message out of a queue:

      The code (fragments) in question - Most/all of this code is lifted from one of the quickstarts follows:

      Inserting message into a queue:
      QueueSession session;
      QueueSender send = session.createSender(que);
      TextMessage tm = session.createTextMessage(msg);

      Reading from the queue:
      QueueConnection conn;
      InitialContext iniCtx; (initialization code omitted from post)
      receiverQueue = (Queue) iniCtx.lookup(receiveQueueName);
      receiverSession = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
      queueReceiver = receiverSession.createReceiver(receiverQueue);
      TextMessage msg = (TextMessage) queueReceiver.receive(2000);

      The last line results in this exception: java.lang.ClassCastException: org.jboss.jms.message.ObjectMessageProxy
      unless it's changed to:

      ObjectMessage msg = (ObjectMessage) queueReceiver.receive(2000);

      Most/all of this code is lifted from one of the quickstarts - but it's not able to read a TextMessage object from the queue - I'm missing something basic here - can anyone suggest what the error is?

      Len DiMaggio