Wildfly16使用mqtt支持设置嵌入式Artemis

时间:2019-04-14 14:58:37

标签: wildfly mqtt activemq-artemis

我正在尝试使用支持mqtt的嵌入式Artemis来设置wildfly16。

这些是我的配置文件

我已经能够将消息从JMS Java客户端和MQTT Java客户端发布到jms-topic jms / topic / test1。我已经能够通过mqtt发布者采样器从Jmetter发送消息。

我已经能够从JMS Java客户端接收消息,但是不可能从任何带有Paho库的mqtt客户端Java客户端订阅主题jms / topic / test1, MQTTBox或Jmeter。

Java客户端进行连接,但在订阅“用户体验(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

MY standalone-full.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>

我的artemis / main / module.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>

1 个答案:

答案 0 :(得分:0)

我回答自己。

一个月后。

深入阅读Apache Artemis用户手册,并在独立版本和wildfly16嵌入式操作系统上进行了许多测试和配置之后,我已经能够在Mqtt支持下的Wildfly中运行Artemis。

正如我在最初的问题中提到的那样,无法从mqtt客户端订阅队列或主题,但是可以将消息发送到该队列/主题。

如果您阅读Artemis手册,则有关预订队列或主题的信息清楚地说明了如何进行预订和发布。

在Artemis中有地址和队列。主题概念不存在。

如果启用了autocreate-address和autocreate-queues,则客户端在发布时将创建地址和队列。

客户端在订阅时也会创建地址和队列。如果每个订阅者不止一个,则在该地址上创建一个队列。

因此,当客户端发布时,将消息发送到该地址,然后Artemis将消息路由到附加的队列。

broker.xml中定义了静态地址和队列。

客户端可以订阅这些静态地址,并且每个客户端都会创建一个动态队列来接收消息。

或者如果程序员希望可以对客户端进行编码,以使其通过完全限定的名称附加到broker.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,则应设置standalone-full.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支持

拉斐尔