如何将STOMP客户端连接到Wildfly?

时间:2015-09-23 12:43:38

标签: wildfly stomp

我想将我的WildFly服务器暴露给STOMP客户端,但我没有找到任何最近的样本。据我所知,最近WildFly版本中的所有通信都通过单个套接字(默认情况下监听8080)。我是否需要更改任何配置或是否支持开箱即用?任何指针都表示赞赏。

3 个答案:

答案 0 :(得分:6)

我使用的是不同版本的WildFly(10.0.CR1),该版本的最小可能变化如下:

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
 ...
  <acceptor name="stomp-acceptor" factory-class="org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory">
    <param name="protocols" value="STOMP"/>
    <param name="port" value="61613"/>
  </acceptor>
 ...
  </server>
</subsystem>

答案 1 :(得分:2)

真正的WildFly默认只侦听端口8080(加上管理端口9990),使用HTTP协议升级切换到不同的协议。

但是,您仍然可以为其他端口定义其他接收器。我不知道是否可以通过端口8080使用STOMP进行协议升级,但是这里有如何为端口5445配置额外的Netty接受器:

<extension module="org.jboss.as.messaging"/>

<subsystem xmlns="urn:jboss:domain:messaging:2.0">
    <hornetq-server>
        <journal-file-size>102400</journal-file-size>
        <connectors>
            <http-connector name="http-connector" socket-binding="http">
                <param key="http-upgrade-endpoint" value="http-acceptor"/>
            </http-connector>
            <http-connector name="http-connector-throughput" socket-binding="http">
                <param key="http-upgrade-endpoint" value="http-acceptor-throughput"/>
                <param key="batch-delay" value="50"/>
            </http-connector>
            <in-vm-connector name="in-vm" server-id="0"/>
        </connectors>
        <acceptors>
            <http-acceptor name="http-acceptor" http-listener="default"/>
            <http-acceptor name="http-acceptor-throughput" http-listener="default">
                <param key="batch-delay" value="50"/>
                <param key="direct-deliver" value="false"/>
            </http-acceptor>
            <netty-acceptor name="stomp-acceptor" socket-binding="messaging-stomp">
                <param key="protocols" value="STOMP"/>
                <param key="connection-ttl" value="30000"/>
            </netty-acceptor>
            <in-vm-acceptor name="in-vm" server-id="0"/>
        </acceptors>
        <security-settings>
            <security-setting match="#">
                <permission type="send" roles="guest"/>
                <permission type="consume" roles="guest"/>
                <permission type="createNonDurableQueue" roles="guest"/>
                <permission type="deleteNonDurableQueue" roles="guest"/>
            </security-setting>
        </security-settings>
        <address-settings>
            <!--default for catch all-->
            <address-setting match="#">
                <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                <max-size-bytes>10485760</max-size-bytes>
                <page-size-bytes>2097152</page-size-bytes>
                <message-counter-history-day-limit>10</message-counter-history-day-limit>
            </address-setting>
        </address-settings>
        <jms-connection-factories>
            <connection-factory name="InVmConnectionFactory">
                <connectors>
                    <connector-ref connector-name="in-vm"/>
                </connectors>
                <entries>
                    <entry name="java:/ConnectionFactory"/>
                </entries>
            </connection-factory>
            <connection-factory name="RemoteConnectionFactory">
                <connectors>
                    <connector-ref connector-name="http-connector"/>
                </connectors>
                <entries>
                    <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                </entries>
            </connection-factory>
            <pooled-connection-factory name="hornetq-ra">
                <transaction mode="xa"/>
                <connectors>
                    <connector-ref connector-name="in-vm"/>
                </connectors>
                <entries>
                    <entry name="java:/JmsXA"/>
                    <entry name="java:jboss/DefaultJMSConnectionFactory"/>
                </entries>
            </pooled-connection-factory>
        </jms-connection-factories>
        <jms-destinations>
            <jms-queue name="ExpiryQueue">
                <entry name="java:/jms/queue/ExpiryQueue"/>
            </jms-queue>
            <jms-queue name="DLQ">
                <entry name="java:/jms/queue/DLQ"/>
            </jms-queue>
        </jms-destinations>
    </hornetq-server>
</subsystem>

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    <socket-binding name="messaging-stomp" port="5445"/>
</socket-binding-group>

此外,您必须通过guest创建一个角色为add-user.sh的用户帐户。该帐户将由STOMP客户端使用。

在WildFly 8.2.0.Final上测试。

答案 2 :(得分:1)

以下conf在我的案例中做了伎俩(WF 10.0.0.Final)

<remote-acceptor name="stomp-acceptor" socket-binding="messaging-stomp">
   <param name="protocols" value="STOMP"/>
   <param name="connection-ttl" value="30000"/>
   <param name="stomp-enable-message-id" value="true"/>
</remote-acceptor>
...
<socket-binding name="messaging-stomp" port="61613"/>