Wildfly 10.1集群中的Spring websockets

时间:2017-08-02 21:24:39

标签: wildfly stomp spring-websocket activemq-artemis wildfly-cluster

使用Wildfly 10.1 standalone-full-ha.xml以及随附的ActiveMQ Artemis 1.1.0。通过将此添加到activemq config:

启用STOMP
<acceptor name="stomp-acceptor" factory-class="org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory">
   <param name="protocols" value="STOMP"/>
   <param name="port" value="${stomp.port:61613}"/>
</acceptor>

根据https://spring.io/guides/gs/messaging-stomp-websocket/

部署了一个示例弹簧腹板战争

我在2台独立的服务器上运行,可以组成一个集群。我可以连接到两台服务器并发送消息,但是当我断开其中一个websockets时,另一台服务器上会抛出以下异常:

16:49:02,377 ERROR [org.apache.activemq.artemis.core.server] (Thread-7 (ActiveMQ-client-global-threads-926891052)) AMQ224037: cluster connection Failed to handle message: java.lang.IllegalStateException: Cannot find binding for ffaa538e-77c3-11e7-ba4b-7b9cb7ee40e2b7e6493a-77c3-11e7-ba4b-7b9cb7ee40e2
        at org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionImpl$MessageFlowRecordImpl.doConsumerClosed(ClusterConnectionImpl.java:1319)
        at org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionImpl$MessageFlowRecordImpl.handleNotificationMessage(ClusterConnectionImpl.java:1005)
        at org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionImpl$MessageFlowRecordImpl.onMessage(ClusterConnectionImpl.java:974)
        at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:1018)
        at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:48)
        at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1145)
        at org.apache.activemq.artemis.utils.OrderedExecutorFactory$OrderedExecutor$ExecutorTask.run(OrderedExecutorFactory.java:103)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

我还使用Wildfly 11 Alpha和随附的ActiveMQ Artemis 1.5.3对此进行了测试,但每次断开websocket时都会出现同样的错误。

当我关闭服务器时,我也会遇到以下错误,但我不太关心这些错误,因为它们只在关机期间发生:

17:11:03,747 ERROR [org.apache.activemq.artemis.core.server] (Thread-27 (ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$2@5669232b-14602972)) AMQ224051: Failed to call notification listener: java.lang.IllegalStateException: No queue 0110e86e-77c4-11e7-a745-252881f696b4
        at org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl.onNotification(PostOfficeImpl.java:387)
        at org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl.sendNotification(ManagementServiceImpl.java:580)
        at org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl.close(ServerConsumerImpl.java:437)
        at org.apache.activemq.artemis.core.server.impl.ServerSessionImpl.doClose(ServerSessionImpl.java:354)
        at org.apache.activemq.artemis.core.server.impl.ServerSessionImpl$1.done(ServerSessionImpl.java:1191)
        at org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl.executeOnCompletion(OperationContextImpl.java:161)
        at org.apache.activemq.artemis.core.server.impl.ServerSessionImpl.close(ServerSessionImpl.java:1185)
        at org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager$1.run(StompProtocolManager.java:276)
        at org.apache.activemq.artemis.utils.OrderedExecutorFactory$OrderedExecutor$ExecutorTask.run(OrderedExecutorFactory.java:103)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

17:11:03,784 ERROR [io.netty.util.concurrent.DefaultPromise.rejectedExecution] (globalEventExecutor-1-2) Failed to submit a listener notification task. Event loop shut down?: java.util.concurrent.RejectedExecutionException: event executor terminated
        at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:821)
        at io.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:327)
        at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:320)
        at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:746)
        at io.netty.util.concurrent.DefaultPromise.safeExecute(DefaultPromise.java:760)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:428)
        at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104)
        at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:82)
        at io.netty.channel.AbstractChannel$CloseFuture.setClosed(AbstractChannel.java:1058)
        at io.netty.channel.AbstractChannel$AbstractUnsafe.doClose0(AbstractChannel.java:686)
        at io.netty.channel.AbstractChannel$AbstractUnsafe.access$700(AbstractChannel.java:419)
        at io.netty.channel.AbstractChannel$AbstractUnsafe$5.run(AbstractChannel.java:646)
        at io.netty.util.concurrent.GlobalEventExecutor$TaskRunner.run(GlobalEventExecutor.java:233)
        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
        at java.lang.Thread.run(Thread.java:745)

17:11:03,797 WARN  [io.netty.channel.AbstractChannel] (globalEventExecutor-1-2) Can't invoke task later as EventLoop rejected it: java.util.concurrent.RejectedExecutionException: event executor terminated
        at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:821)
        at io.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:327)
        at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:320)
        at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:746)
        at io.netty.channel.AbstractChannel$AbstractUnsafe.invokeLater(AbstractChannel.java:931)
        at io.netty.channel.AbstractChannel$AbstractUnsafe.access$900(AbstractChannel.java:419)
        at io.netty.channel.AbstractChannel$AbstractUnsafe$5.run(AbstractChannel.java:649)
        at io.netty.util.concurrent.GlobalEventExecutor$TaskRunner.run(GlobalEventExecutor.java:233)
        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
        at java.lang.Thread.run(Thread.java:745)

弹簧websocket示例是否存在问题?

我是否需要更改默认的standalone-full-ha.xml中的某些内容才能使其在群集中正常工作,而不会在客户端断开连接上抛出异常?

1 个答案:

答案 0 :(得分:0)

Wildfly的Artemis版本落后于最新的上游版本(1.5.3 vs 2.2.0)。您是否尝试过使用独立的Artemis 2.2.0节点集群?