我正在尝试设置带有嵌入式Artemis的wildfly16,并支持mqtt。
这些是我的配置文件
我已经能够从JMS java客户端和MQTT java客户端将消息发布到jms-topic jms/topic/test1。我已经能够通过 mqtt 发布者采样器从 Jmetter 发送消息。
我已经能够从JMS java客户端接收消息,但是无法从任何带有paho库的mqtt客户端Java客户端订阅主题jms/topic/test1, MQTTBox 或 Jmeter。
Java 客户端连接,但在订阅"Se ha perdido la conexión (32109) - java.io.EOFException"时引发异常
因此,我非常感谢有关此问题的任何帮助。
我的野蝇奔跑
16:15:24,632 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221012: Using AIO Journal
16:15:24,621 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
16:15:24,890 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221043: Protocol module found: [artemis-server]. Adding protocol support for: CORE
16:15:24,890 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221043: Protocol module found: [artemis-mqtt-protocol]. Adding protocol support for: MQTT
16:15:24,891 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221043: Protocol module found: [artemis-amqp-protocol]. Adding protocol support for: AMQP
16:15:24,891 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221043: Protocol module found: [artemis-hornetq-protocol]. Adding protocol support for: HORNETQ
16:15:24,891 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221043: Protocol module found: [artemis-stomp-protocol]. Adding protocol support for: STOMP
16:15:24,940 INFO [org.jboss.ws.common.management] (MSC service thread 1-4) JBWS022052: Starting JBossWS 5.2.4.Final (Apache CXF 3.2.7)
16:15:25,056 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221034: Waiting indefinitely to obtain live lock
16:15:25,056 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221035: Live Server Obtained live lock
16:15:25,838 INFO [org.wildfly.extension.messaging-activemq] (MSC service thread 1-4) WFLYMSGAMQ0016: Registered HTTP upgrade for activemq-remoting protocol handled by http-acceptor acceptor
16:15:25,842 INFO [org.wildfly.extension.messaging-activemq] (MSC service thread 1-2) WFLYMSGAMQ0016: Registered HTTP upgrade for activemq-remoting protocol handled by http-acceptor-throughput acceptor
16:15:25,843 INFO [org.wildfly.extension.messaging-activemq] (MSC service thread 1-3) WFLYMSGAMQ0016: Registered HTTP upgrade for activemq-remoting protocol handled by http-acceptor-throughput acceptor
16:15:25,838 INFO [org.wildfly.extension.messaging-activemq] (MSC service thread 1-1) WFLYMSGAMQ0016: Registered HTTP upgrade for activemq-remoting protocol handled by http-acceptor acceptor
16:15:26,081 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221020: Started EPOLL Acceptor at 127.0.0.1:1883 for protocols [MQTT]
16:15:26,121 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221007: Server is now live
16:15:26,121 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.6.3.jbossorg-00014 [default, nodeID=b81df2c8-5d5e-11e9-a53d-14dae99243d9]
16:15:26,139 INFO [org.wildfly.extension.messaging-activemq] (ServerService Thread Pool -- 81) WFLYMSGAMQ0002: Bound messaging object to jndi name java:/ConnectionFactory
16:15:26,242 INFO [org.wildfly.extension.messaging-activemq] (ServerService Thread Pool -- 86) WFLYMSGAMQ0006: Unbound messaging object to jndi name java:jboss/exported/jms/queue/test
16:15:26,243 INFO [org.wildfly.extension.messaging-activemq] (ServerService Thread Pool -- 86) WFLYMSGAMQ0002: Bound messaging object to jndi name java:jboss/exported/jms/queue/test
16:15:26,248 INFO [org.wildfly.extension.messaging-activemq] (ServerService Thread Pool -- 84) WFLYMSGAMQ0002: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
16:15:26,313 INFO [org.jboss.as.connector.deployment] (MSC service thread 1-5) WFLYJCA0007: Registered connection factory java:/JmsXA
16:15:26,329 INFO [org.jboss.as.connector.deployment] (MSC service thread 1-7) WFLYJCA0011: Unbound JCA ConnectionFactory [java:/JmsXA]
16:15:26,330 INFO [org.jboss.as.connector.deployment] (MSC service thread 1-8) WFLYJCA0119: Unbinding connection factory named java:/JmsXA to alias java:jboss/DefaultJMSConnectionFactory
16:15:26,498 INFO [org.apache.activemq.artemis.ra] (MSC service thread 1-5) AMQ151007: Resource adaptor started
16:15:26,498 INFO [org.jboss.as.connector.services.resourceadapters.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-5) IJ020002: Deployed: file://RaActivatoractivemq-ra
16:15:26,531 INFO [org.jboss.as.connector.deployment] (MSC service thread 1-2) WFLYJCA0002: Bound JCA ConnectionFactory [java:/JmsXA]
16:15:26,535 INFO [org.jboss.as.connector.deployment] (MSC service thread 1-2) WFLYJCA0118: Binding connection factory named java:/JmsXA to alias java:jboss/DefaultJMSConnectionFactory
16:15:26,885 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
16:15:26,888 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV00
我的单机满满.xml
<subsystem xmlns="urn:jboss:domain:messaging-activemq:6.0">
<server name="default">
<statistics enabled="${wildfly.messaging-activemq.statistics-enabled:${wildfly.statistics-enabled:false}}" />
<security-setting name="#">
<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true" />
</security-setting>
<address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10" />
<http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor" />
<http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
<param name="batch-delay" value="50" />
</http-connector>
<in-vm-connector name="in-vm" server-id="0">
<param name="buffer-pooling" value="false" />
</in-vm-connector>
<remote-connector name="remote_conector" socket-binding="mqtt" />
<http-acceptor name="http-acceptor" http-listener="default" />
<http-acceptor name="http-acceptor-throughput" http-listener="default">
<param name="batch-delay" value="50" />
<param name="direct-deliver" value="false" />
</http-acceptor>
<remote-acceptor name="mqtt-acceptor" socket-binding="mqtt">
<param name="protocols" value="MQTT" />
<param name="batch-delay" value="50" />
<param name="direct-deliver" value="true" />
</remote-acceptor>
<in-vm-acceptor name="in-vm" server-id="0">
<param name="buffer-pooling" value="false" />
</in-vm-acceptor>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue" />
<jms-queue name="DLQ" entries="java:/jms/queue/DLQ" />
<jms-queue name="test" entries="java:/jms/queue/test java:jboss/exported/jms/queue/test" />
<jms-topic name="test1" entries="java:jboss/exported/jms/topic/test1 java:/jms/topic/test1" />
<jms-topic name="test2" entries="java:/jms/topic/test2 java:jboss/exported/jms/topic/test2" />
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm" />
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector" />
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa" />
</server>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}" />
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}" />
<socket-binding name="ajp" port="${jboss.ajp.port:8009}" />
<socket-binding name="http" port="${jboss.http.port:8080}" />
<socket-binding name="https" port="${jboss.https.port:8443}" />
<socket-binding name="txn-recovery-environment" port="4712" />
<socket-binding name="txn-status-manager" port="4713" />
<socket-binding name="iiop" interface="unsecure" port="3528" />
<socket-binding name="iiop-ssl" interface="unsecure" port="3529" />
<socket-binding name="mqtt" port="1883" />
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25" />
</outbound-socket-binding>
</socket-binding-group>
我的阿尔忒弥斯/主/模块.xml
module name="org.apache.activemq.artemis" xmlns="urn:jboss:module:1.5">
<resources>
<resource-root path="artemis-core-client-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-selector-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-server-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-cli-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-dto-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-hqclient-protocol-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-jdbc-store-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-jms-client-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-jms-server-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-service-extensions-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-tools-2.6.3.jbossorg-00014.jar" />
<resource-root path="artemis-mqtt-protocol-2.6.3.jbossorg-00014.jar" />
</resources>
<dependencies>
<module name="com.google.guava" />
<module name="javax.api" />
<module name="javax.jms.api" />
<module name="javax.json.api" />
<module name="org.apache.commons.beanutils" />
<module name="org.apache.activemq.artemis.journal" export="true" />
<module name="org.jboss.jts" />
<module name="org.jboss.logging" />
<module name="io.netty" />
<module name="org.jgroups" />
<module name="javax.resource.api" />
<!-- WFLY-5213 Optional dependency to use the org.apache.activemq.artemis as a naming's external-context module -->
<module name="org.jboss.invocation" optional="true" />
<module name="org.jboss.jboss-transaction-spi" />
<!--this reverse dependency is here so integration classes in the AS code base can be instantiated by Artemis-->
<module name="org.wildfly.extension.messaging-activemq" services="import" />
<module name="org.jboss.as.security" />
<module name="org.picketbox" />
<!-- this optional dependency is required to be able to use this module from a jms-bridge to connect to a remote
WildFly server [AS7-6549] -->
<module name="org.wildfly.naming-client" optional="true" services="import" />
<!-- https://issues.jboss.org/browse/AS7-4936 this is to avoid an issue on IBM JDK -->
<module name="sun.jdk" />
<!-- supported protocols (in addition to the CORE protocol) -->
<module name="org.apache.activemq.artemis.protocol.amqp" services="import" optional="true" />
<module name="org.apache.activemq.artemis.protocol.hornetq" services="import" optional="true" />
<module name="org.apache.activemq.artemis.protocol.stomp" services="import" optional="true" />
<module name="org.apache.activemq.artemis.protocol.mqtt" services="import" optional="true" />
</dependencies>
</module>
我的artemis/protocol/mqtt/module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="org.apache.activemq.artemis.protocol.mqtt">
<resources>
<resource-root path="artemis-mqtt-protocol-2.6.3.jbossorg-00014.jar" />
<resource-root path="netty-codec-4.1.34.Final.jar" />
<resource-root path="netty-all-4.1.34.Final.jar" />
</resources>
<dependencies>
<module name="io.netty" />
<module name="org.apache.activemq.artemis" />
<module name="org.jboss.logging" />
</dependencies>
</module>
我回答自己。
一个月后。
在深入阅读了Apache Artemis用户手册,并在独立和wildfly16嵌入式上进行了许多测试和配置之后,我已经能够在Mqtt支持下在Wildfly中运行Artemis。
正如我在最初的问题中提到的,不可能从 mqtt 客户端订阅队列或主题,但是可以将消息发送到该队列/主题。
如果您阅读了Artemis手册,有关订阅队列或主题的信息清楚地解释了订阅和发布的方式。
在阿尔忒弥斯有地址和队列。 主题概念不存在。
如果启用了自动创建地址和自动创建队列,则客户端在发布时将创建地址和队列。
订阅时的客户端也将创建地址和队列。如果有多个订阅者,则每个订阅者都会创建一个附加到地址的队列。
因此,当客户端发布时,会将消息发送到地址,Artemis将消息路由到附加的队列。
存在代理.xml中定义的静态地址和队列。
客户端可以订阅这些静态地址,并将创建一个动态队列,每个地址以接收消息。
或者如果程序员希望可以编码客户端以便通过完全限定名附加到代理中定义的静态队列.xml。
broker.xml static address and queue
</address>
<address name="test">
<multicast>
<queue name="T1" />
</multicast>
</address>
client, field for fully qualyfied name
private String topic = "test::T1";
因此,如果您想从 Mqtt 客户端订阅 Wildfly16 Artemis,您应该设置独立完整.xml以允许自动创建队列。
<address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10" auto-create-queues="true" auto-delete-queues="true" auto-create-addresses="true" auto-delete-addresses="true"/>
仅此而已,允许客户端创建附加到地址的自己的队列。
感谢贾斯汀·贝尔特拉姆(Justin Beltram)对Wildfly日志的建议。调试模式下的日志级别给了我线索。
现在我将尝试在 Wildfly16 中为 Artemis设置 SSL 支持
拉斐尔