1 Reply Latest reply on Sep 8, 2006 11:45 AM by jaikiran pai

    Regarding SpyObjectMessage in JMS

    chaitanya gogineni Newbie

      Hi,
      I am trying to use JMSAppender for Loggins. It is sending messages to Topic. I have a MDB that reads messages from topic.

      If it is a TextMessage it prints directly on the console.

      If is not a TextMessage it findouts what type of message it is and displays that on the screen.

      My MDB code is

      if (inMessage instanceof TextMessage) {
      log.info("MESSAGE BEAN: Message received: "msg.getText());
      }
      else {
      log.warn("Message of wrong type: " inMessage.getClass().getName());
      }

      THe OUTPUT is
      "Message of wrong type: org.jboss.mq.SpyObjectMessage"


      Can anyboy help me how to covert the SpyObjectMessage to a TextMessage or how to display the text in a SpyObjectMessage

        • 1. Re: Regarding SpyObjectMessage in JMS
          jaikiran pai Master

           

          Can anyboy help me how to covert the SpyObjectMessage to a TextMessage or how to display the text in a SpyObjectMessage

          JMS Message can be of different types:
          1) BytesMessage
          2) MapMessage
          3) ObjectMessage
          4) StreamMessage
          5) TextMessage

          In short, the Message that you receive need not contain text. It can be of any of the above mentioned types. So you cannot get text out of a Message which is of type MapMessage or some other Message.

          Why are you trying to print the message contents, if its not a TextMessage?