1 Reply Latest reply on May 5, 2011 8:06 AM by Michael Justin

    Stomp text message appearing as JMS BytesMessage in JBoss AS 6

    Michael Justin Novice

      This Stomp frame


      Message: 0 sent at: 05.05.2011 09:51:51


      appears as a JMS BytesMessage in JBoss AS 6.0.0.Final, is this by design?


      I am testing with this code in a JavaServer Faces backing bean, but will try to reproduce it with a simple HornetQ client app.


      package demo;
      import java.util.logging.*;
      import javax.annotation.Resource;
      import javax.faces.bean.ManagedBean;
      import javax.jms.*;
      public class Bean {
          @Resource(mappedName = "java:/ConnectionFactory")
          private ConnectionFactory connectionFactory;
          @Resource(mappedName = "/queue/TOOL.DEFAULT")
          private Queue queue;
          public String getMessage() {
              String result = "no message";
              Logger.getLogger(Bean.class.getName()).log(Level.INFO, "checking");
              try {
                  Connection connection = connectionFactory.createConnection();
                  Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                  MessageConsumer consumer = session.createConsumer(queue);
                  Message message = consumer.receiveNoWait();
                  if (message != null) {
                      if (message instanceof BytesMessage) {
                        result = "bytes - " + ((BytesMessage) message).getBodyLength();
                      } else if (message instanceof TextMessage) {
                          result = ((TextMessage) message).getText();
                  } else {
                      Logger.getLogger(Bean.class.getName()).log(Level.INFO, "no message...");
              } catch (JMSException ex) {
                  Logger.getLogger(Bean.class.getName()).log(Level.SEVERE, ex.getMessage());
              return result;



      Michael Justin