Java 使用MQTT主题的ActiveMQ Spring集成

Java 使用MQTT主题的ActiveMQ Spring集成,java,activemq,mqtt,spring-jms,Java,Activemq,Mqtt,Spring Jms,我是activemq的新手。我正在activeMQ中创建一个主题。和am通过mqtt发布数据 mosquitto_pub -d -t testTopic -m "test message" 但我收到了一条错误信息 错误:消息不是预期的TextMessage类型 这是我的密码 public void onMessage(Message message) { if (message instanceof TextMessage) { } else

我是activemq的新手。我正在activeMQ中创建一个主题。和am通过mqtt发布数据

mosquitto_pub   -d -t testTopic -m "test message"
但我收到了一条错误信息

错误:消息不是预期的TextMessage类型

这是我的密码

    public void onMessage(Message message) {
     if (message instanceof TextMessage) {


      }
      else
      {

        logger.error("Message is not of expected type TextMessage.");
      }
}
实际问题是什么。但是iam成功地通过http将数据发送到同一主题


任何想法…?

在ActiveMQ Spring消费者中,http消息是文本消息的类型,mqtt消息是ByteMessage的类型。因为我需要添加一些代码

if (message instanceof BytesMessage) {
                BytesMessage bm = (BytesMessage) message;
                byte data[];
                data = new byte[(int) bm.getBodyLength()];
                bm.readBytes(data);
                msgText = new String(data);
                System.out.println("Message String = "+msgText);
}

你需要提供更多的信息,完整的错误,谁在记录错误等,我得到了问题。在我的代码中,输入数据是字节消息的类型。但是如何获取实际消息呢