java – 如何使用ActiveMQ设置Spring Cloud Bus?
作者:互联网
我想在我的项目中使用Spring Cloud Bus来动态更新配置.
我们的环境中已经有Apache ActiveMQ.
是否有可能使用ActiveMQ而不是RabbitMQ作为经纪人?
它们都是一种AMQP服务器.
我在pom.xml中设置依赖关系,如下所示:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
它看起来像标准的AMQP启动器,不仅限于RabbitMQ.
但是,配置服务器启动时会出现以下错误日志:
org.springframework.amqp.AmqpIOException: java.io.IOException
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:65)
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:218)
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:476)
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:80)
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:130)
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:67)
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:439)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1083)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: null
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 org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:205)
... 7 common frames omitted
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)
... 9 common frames omitted
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 common frames omitted
解决方法:
Is there any possible to use ActiveMQ instead RabbitMQ as the broker?
据我所知,ActiveMQ只提供AMQP 1.0,而兔子客户端是0.9.1,所以答案是“不”.如果您为AMQP 1.0或JMS或ActiveMQ中的其他协议之一提供了spring-cloud-stream绑定器,那么您可以以这种方式使用它(在Spring Cloud的Brixton版本中).它们并不是现成的,所以你必须自己写一下.
标签:java,spring-cloud-2 来源: https://codeday.me/bug/20190623/1270103.html