java - 具有独立 ActiveMQ 的 Wildfly 上的 ActiveMQ Artemis

标签 java jms wildfly activemq-artemis

我正在尝试使用MDB连接wildfly 10服务器,使用内置的ActiveMQ Artemis连接到运行版本5.13.3的独立ActiveMQ服务器。 Artemis 似乎无法与任何受支持的 ActiveMQ 协议(protocol)进行通信。


ActiveMQ 独立代理具有以下transportConnectors:

<transportConnectors>
    <transportConnector name="auto" uri="auto://localhost:5671?protocolDetectionTimeOut=5000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="http" uri="http://0.0.0.0:8180?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600" />
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
</transportConnectors>

Wildfly MessageBean 具有以下注释:

@MessageDriven(activationConfig =
{
        @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
        @ActivationConfigProperty(propertyName="destination", "TestDestination"),
        @ActivationConfigProperty(propertyName="clientID", propertyValue = "test"),
        @ActivationConfigProperty(propertyName="connectionParameters", propertyValue = "host=127.0.0.1;port=5671"),  
        @ActivationConfigProperty(propertyName="connectorClassName", propertyValue = "org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory"),
        @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="Auto-acknowledge")
}, mappedName = "TestDestination")
public class MessageProcessingBean implements MessageListener {

根据我选择连接的连接器,我在 ActiveMQ 服务器上收到不同的错误消息。

连接到 auto 端点会产生以下消息:

ERROR | Could not accept connection : java.lang.IllegalStateException: Could not detect the wire format

wildfly 端没有错误。


连接到 Openwire 端点会产生以下消息:

WARN | Transport Connection to: tcp://127.0.0.1:45000 failed: java.io.IOException: Unknown data type: 77

这也会在 Wildfly 端产生错误:

17:04:23,384 ERROR [org.apache.activemq.artemis.core.client] (Thread-16 (ActiveMQ-client-netty-threads-1716275972)) > AMQ214013: Failed to decode packet: java.lang.IllegalArgumentException: AMQ119032: Invalid type: 1 at org.apache.activemq.artemis.core.protocol.core.impl.PacketDecoder.decode(PacketDecoder.java:413) at org.apache.activemq.artemis.core.protocol.ClientPacketDecoder.decode(ClientPacketDecoder.java:60) at org.apache.activemq.artemis.core.protocol.ClientPacketDecoder.decode(ClientPacketDecoder.java:39) at org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl.bufferReceived(RemotingConnectionImpl.java:324) at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl$DelegatingBufferHandler.bufferReceived(ClientSessionFactoryImpl.java:1105) at org.apache.activemq.artemis.core.remoting.impl.netty.ActiveMQChannelHandler.channelRead(ActiveMQChannelHandler.java:68) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) at java.lang.Thread.run(Thread.java:745)

我可以继续下去并在所有端点上接收错误消息。事实上,结果是 ActiveMQ-Artemis 正在以 ActiveMQ 不支持的数据格式发送。

必须采取哪些步骤才能将 ActiveMQ-Artemis 与独立的 ActiveMQ-Server 连接?

最佳答案

Wildfly 10 附带 ActiveMQ Artemis,默认情况下任何 MDB 都将使用 ActiveMQ Artemis JCA RA。 ActiveMQ Artemis JCA RA 使用 core 协议(protocol),该协议(protocol)仅受 ActiveMQ Artemis 代理支持。 ActiveMQ 5.x 代理无法/不会理解此协议(protocol)。

因此,如果您希望在 Wildfly 10 上运行的 MDB 能够使用来自 ActiveMQ 5.x 代理的消息,那么您需要部署 ActiveMQ 5.x JCA RA(采用 OpenWire ActiveMQ 5.x 代理理解的协议(protocol))并配置 MDB 以使用该协议(protocol)(例如通过激活配置属性)。

就其值(value)而言,ActiveMQ Artemis 代理确实支持 OpenWire 协议(protocol),因此旧版 ActiveMQ 5.x 客户端可以连接到 ActiveMQ Artemis 代理。

关于java - 具有独立 ActiveMQ 的 Wildfly 上的 ActiveMQ Artemis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38399410/

相关文章:

java - 在JAVA中使用CopyManager从Collection快速插入postgresql DB

java - 为什么 Map 不是 "true"集合?

rabbitmq - 当消息发布到没有订阅者的队列上时会发生什么?

jax-rs - 使用 RESTEasy、Weld 和 Wildfly 失败的 @Inject 对象

带有脚本参数的 Docker 入口点

java - 焊接-001408 : Unsatisfied dependencies for type Validator with qualifiers @Default

java - JVM 系统属性 - 如何将其视为字符串文字

java - Terracotta 是否使 JMS 成为一个不需要的层?

jms - RabbitMQ 扇出交换(VirtualTopic 等效)

java - 无需安装即可部署 Magnolia CMS