Spring boot 集成RabbitMQ 连接超时

org.springframework.amqp.AmqpTimeoutException:
java.util.concurrent.TimeoutException at
org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:74)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:476)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:614)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:240)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1797)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1771)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1752)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:338)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1604)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainerAsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:963)
[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at
java.base/java.lang.Thread.run(Thread.java:844) [na:na] Caused by:
java.util.concurrent.TimeoutException: null at
com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:77)
~[amqp-client-5.1.2.jar:5.1.2] at
com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:120)
~[amqp-client-5.1.2.jar:5.1.2] at
com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
~[amqp-client-5.1.2.jar:5.1.2] at
com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:494)
~[amqp-client-5.1.2.jar:5.1.2] at
com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:306)
~[amqp-client-5.1.2.jar:5.1.2] at
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:957)
~[amqp-client-5.1.2.jar:5.1.2] at
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:907)
~[amqp-client-5.1.2.jar:5.1.2] at
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:847)
~[amqp-client-5.1.2.jar:5.1.2] at
org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:449)
~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] … 9 common frames
omitted

刚开始做springboot整合rabbitMQ的时候,我们都知道MQ的本地端口默认是:15672
所以我们以为在yml或者properties配置文件中我们给MQ配置的地址也应该是这样的:

server:
  port: 8080
spring:
  #给项目来个名字
  application:
    name: rabbitmq-provider
  #配置rabbitMq 服务器
  rabbitmq:
    host: 127.0.0.1
    port: 15672
    username: guest
    password: guest

    #确认消息已发送到交换机(Exchange)

    publisher-returns: true
    publisher-confirm-type: correlated

然而,我们一顿骚操作,报错还是这样。
于是乎,面向百度编程而来:

官方解释:

5672, 5671: used by AMQP 0-9-1 and 1.0 clients without and with TLS

15672: HTTP API clients and rabbitmqadmin (only if the management plugin is enabled)

大意为:
15672是Web管理界面的端口;
5672是MQ访问的端口。

所以我们将15672改成5672就可以了!

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页