简体   繁体   English

Rabbit MQ无法从Spring Boot Run启动(连接被拒绝)

[英]Rabbit MQ Fails to start with Spring Boot Run (Connection Refused)

I was going to post this question but I think I've found an answer. 我本来打算发布这个问题,但我想我已经找到了答案。 I'm hoping someone can provide a reason why to further public knowledge. 我希望有人能提供一个进一步了解公众知识的理由。

I am integrating RabbitMQ into my Spring Boot Application. 我正在将RabbitMQ集成到我的Spring Boot应用程序中。

Upon startup of my Spring boot Application I keep getting this stack trace 在启动Spring Boot Application之后,我会不断获取此堆栈跟踪

org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
    at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:62) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:484) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:626) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:240) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1797) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1771) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1752) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
... 
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_172]
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_172]
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_172]
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_172]
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_172]

I've cut RabbitMQ to bare bones and only have the dependency in the pom.xml and have the following in application.properties 我已经将RabbitMQ切开了,只在pom.xml具有依赖项,而在application.properties具有以下内容

spring.rabbitmq.host=localhost
spring.rabbitmq.port=15672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

I verified that Rabbit MQ was up and running and could even go into the GUI 我验证了Rabbit MQ已启动并正在运行,甚至可以进入GUI

My solution was to change spring.rabbitmq.port to 5672 (removing the 1) 我的解决方案是将spring.rabbitmq.port更改为5672 (删除1)

Can anyone provide a technical answer? 谁能提供技术答案? Is it because RabbitMQ listens on that port 5672 and provides the front end only on 15672 是因为RabbitMQ侦听该端口5672并仅在15672上提供前端

RabbitMq uses Advanced Message Queuing Protocol (AMQP). RabbitMq使用高级消息队列协议(AMQP)。

In rabbitmq.conf the tcp port provided takes the port of the RabbitMq from your Java Application. 在Rabbitmq.conf中,提供的tcp端口从Java应用程序获取RabbitMq的端口。

listeners.tcp.default = 5672 listeners.tcp.default = 5672

RabbitMQ Management console or the Web Admin uses the 15672 (default) port. RabbitMQ管理控制台或Web管理员使用15672(默认)端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM