gpt4 book ai didi

java - 在同一台机器上同时运行 ActiveMQ 和 RabbitMQ 时 AMQP 协议(protocol)版本不匹配

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:40:28 25 4
gpt4 key购买 nike

我一直在尝试开发一个同时使用 activeMQ 和 rabbitMQ 的项目。我在下面列出的 pom.xml 中添加的依赖项:

    <dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.4.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>5.13.0</version>
</dependency>

另外,我运行 apache-activemq-5.13.0rabbitmq-server-3.5.6同时。但不幸的是,我遇到了一个与 AMQP 相关的错误,如下所示:

java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:350)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:648)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:678)
at org.hafiz.framework.common.rabbit.filter.ReceiveRabbitMessageFilter.init(ReceiveRabbitMessageFilter.java:33)
at org.hafiz.common.filter.PrmTarrifTypeMessageFilter.init(PrmTarrifTypeMessageFilter.java:21)

at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4854)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5546)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)

at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1263)

at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1948)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:37)

at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:367)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:293)
... 20 more
Caused by: com.rabbitmq.client.MalformedFrameException: AMQP protocol version mismatch; we are version 0-9-1, server sent signature 0,1,0,0
at com.rabbitmq.client.impl.Frame.protocolVersionMismatch(Frame.java:174)
at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:111)

at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:139)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:536)
... 1 more
java.lang.NullPointerException
at org.hafiz.framework.common.rabbit.filter.ReceiveRabbitMessageFilter.receiveMessage(ReceiveRabbitMessageFilter.java:61)
at org.hafiz.common.filter.PrmTarrifTypeMessageFilter$1.run(PrmTarrifTypeMessageFilter.java:29)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

如果有人帮助我解决这个错误,我将不胜感激。

最佳答案

解决方案只是更改其中一个消息代理端口号。由于它们都在同一个端口 (5672) 上工作,您应该只更改其中一个的配置。

对于 rabbitMQ,您可以按照 here 中解释的说明进行休假,就像@Kenney说的一样简单,就是设置一个环境变量。

注意:设置变量时不要忘记重新安装RabbitMQ服务。

在 Windows 中,您可以通过在命令提示符下运行以下命令来执行此操作:

  1. cd进入RabbitMQ服务器安装目录下的sbin文件夹,运行rabbitmq-service.bat remove
  2. 设置 RABBITMQ_NODE_PORT=xxxx
  3. rabbitmq-service.bat 安装

此外,如果它不起作用,您只需将 ActiveMQ 的默认端口更改为 amqp。为此,您应该在位于 ActiveMQ 服务器安装目录的 conf 文件夹中查找文件名 activemq.xml。我希望这对你有用。

关于java - 在同一台机器上同时运行 ActiveMQ 和 RabbitMQ 时 AMQP 协议(protocol)版本不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34314016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com