java使用Wildlfy 11嵌入式Apache Artemis接收MQTT消息
我希望通过嵌入的Apache Artemis在Wildfly 11中接收MQTT消息
当前状态:
我向Wildfly嵌入式Apache Artemis添加了MQTT协议支持(添加了“缺失”文件夹和Artemis MQTT协议-.jar,并在module.xml中启用了该协议)
我正在使用完整的独立配置,并为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添加到socket绑定中
从日志中我可以看出它是有效的:
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
所以看起来我在某个地方丢失了一些绑定,但我找不到它会是什么。有人知道吗
# 1 楼答案
看起来有两个问题:
# 2 楼答案
日志上写着:
它还说:
所以在我看来,这就像是“jms.topic.testEndpoint”和“testEndpoint”之间的简单不匹配