gpt4 book ai didi

java - 使用 Wildlfy 11 嵌入的 Apache Artemis 接收 MQTT 消息

转载 作者:行者123 更新时间:2023-11-30 06:21:44 25 4
gpt4 key购买 nike

我想在带有嵌入式 Apache Artemis 的 Wildfly 11 中接收 MQTT 消息。

当前状态:

  1. 我向 Wildfly 嵌入式 Apache Artemis 添加了 MQTT 协议(protocol)支持(添加了“缺失”文件夹和 artemis-mqtt-protocol-.jar 并在 module.xml 中启用了该协议(protocol))

    <
  2. 我正在使用完整的独立配置并为 MTQQ 添加了接受器:

<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
<remote-acceptor name="mqtt-acceptor" socket-binding="mqtt">
<param name="protocols" value="MQTT"/>
</remote-acceptor>

主题为:

<jms-topic name="testEndpoint" entries="java:/jms/testEndpoint"/>
  • 还将 mqtt 添加到套接字绑定(bind)
  • 从日志中我可以看到它有效:

    AMQ221020: Started Acceptor at 127.0.0.1:1883 for protocols [MQTT]

    AMQ221007: Server is now live AMQ221001: Apache ActiveMQ Artemis Message Broker version 1.5.5.jbossorg-008

    AMQ221003: Deploying queue jms.queue.DLQ

    WFLYMSGAMQ0002: Bound messaging object to jndi name java:/ConnectionFactory

    AMQ221003: Deploying queue jms.queue.ExpiryQueue

    WFLYMSGAMQ0002: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory

    AMQ221052: Deploying topic jms.topic.testEndpoint

  • 接下来我编写了一个简单的 MDB:


  • @MessageDriven(
    activationConfig = { @ActivationConfigProperty(propertyName = "destination",
    propertyValue = "testEndpoint"),
    @ActivationConfigProperty(propertyName = "destinationType",
    propertyValue = "javax.jms.Topic")
    },
    mappedName = "testEndpoint")
    public class TestEndpoint implements MessageListener {

    private static final Logger logger = Logger.getLogger(TestEndpoint.class.getName());

    public void onMessage(Message message) {
    try {
    logger.debug("message: " + message.getClass().getName());
    } catch (Exception e) {
    logger.debug("exception: " + e.getMessage());
    }
    }

    }

  • 我可以通过端口 1883 连接到服务器,当我向 testEndpoint 发送消息时,我可以在日志中看到:
  • SESSION CREATED: 63f14f85-0fa2-4fe7-a27b-03ef8e6639a2

    Couldn't find any bindings for address=testEndpoint on message=ServerMessage[messageID=962,durable=true,userID=null,priority=0, bodySize=512, timestamp=0,expiration=0, durable=true, address=testEndpoint,properties=TypedProperties[mqtt.message.retain=true,mqtt.qos.level=1]]@749653273

    Message ServerMessage[messageID=962,durable=true,userID=null,priority=0, bodySize=512, timestamp=0,expiration=0, durable=true, address=testEndpoint,properties=TypedProperties[mqtt.message.retain=true,mqtt.qos.level=1]]@749653273 is not going anywhere as it didn't have a binding on address:testEndpoint

    QueueImpl[name=$sys.mqtt.retain.testEndpoint, postOffice=PostOfficeImpl [server=ActiveMQServerImpl::serverUUID=c58c74d5-ea71-11e7-9621-a434d929f4aa]]@6ff93fb4 doing deliver. messageReferences=0

    所以看起来我在某处缺少一些绑定(bind),但我找不到它是什么。有人有什么想法吗?

    最佳答案

    日志是这样说的:

    AMQ221052: Deploying topic jms.topic.testEndpoint

    它还这样说:

    Couldn't find any bindings for address=testEndpoint

    所以在我看来,这只是“jms.topic.testEndpoint”和“testEndpoint”之间的简单不匹配。

    关于java - 使用 Wildlfy 11 嵌入的 Apache Artemis 接收 MQTT 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48012636/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com