当前位置:   article > 正文

springboot集成rabbitMq遇到的坑_cannot force queue declarations during start

cannot force queue declarations during start
spring.application.name=rabbitmq

spring.rabbitmq.host=127.0.0.1
spring.rabbitmq.port=15672
spring.rabbitmq.username=huitao
spring.rabbitmq.password=1234
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

这是配置文件!

2018-12-08 13:22:04.617 ERROR 5172 --- [127.0.0.1:15672] c.r.c.impl.ForgivingExceptionHandler     : An unexpected connection driver error occured

java.net.SocketException: Socket Closed
	at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_101]
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_101]
	at java.net.SocketInputStream.read(SocketInputStream.java:170) ~[na:1.8.0_101]
	at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_101]
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_101]
	at java.io.BufferedInputStream.read(BufferedInputStream.java:265) ~[na:1.8.0_101]
	at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) ~[na:1.8.0_101]
	at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:164) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:596) ~[amqp-client-5.4.3.jar:5.4.3]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

2018-12-08 13:22:04.617 ERROR 5172 --- [cTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer : Failed to check/redeclare auto-delete queue(s).

org.springframework.amqp.AmqpTimeoutException: java.util.concurrent.TimeoutException
	at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:74) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:509) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:684) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:214) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1961) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1935) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1916) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:393) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1722) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1026) [spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]
Caused by: java.util.concurrent.TimeoutException: null
	at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:77) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:120) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:494) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:315) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1104) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1054) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:994) ~[amqp-client-5.4.3.jar:5.4.3]
	at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:462) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	... 9 common frames omitted

2018-12-08 13:22:04.620  INFO 5172 --- [cTaskExecutor-1] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: [127.0.0.1:15672]
2018-12-08 13:22:09.620 ERROR 5172 --- [127.0.0.1:15672] c.r.c.impl.ForgivingExceptionHandler     : An unexpected connection driver error occured

java.net.SocketException: Socket Closed
	at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_101]
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_101]
	at java.net.SocketInputStream.read(SocketInputStream.java:170) ~[na:1.8.0_101]
	at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_101]
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_101]
	at java.io.BufferedInputStream.read(BufferedInputStream.java:265) ~[na:1.8.0_101]
	at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) ~[na:1.8.0_101]
	at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:164) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:596) ~[amqp-client-5.4.3.jar:5.4.3]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

2018-12-08 13:22:09.621  INFO 5172 --- [           main] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: [127.0.0.1:15672]
2018-12-08 13:22:14.623  INFO 5172 --- [           main] o.s.a.r.l.SimpleMessageListenerContainer : Broker not available; cannot force queue declarations during start
2018-12-08 13:22:14.623 ERROR 5172 --- [127.0.0.1:15672] c.r.c.impl.ForgivingExceptionHandler     : An unexpected connection driver error occured

java.net.SocketException: Socket Closed
	at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_101]
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_101]
	at java.net.SocketInputStream.read(SocketInputStream.java:170) ~[na:1.8.0_101]
	at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_101]
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_101]
	at java.io.BufferedInputStream.read(BufferedInputStream.java:265) ~[na:1.8.0_101]
	at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) ~[na:1.8.0_101]
	at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:164) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:596) ~[amqp-client-5.4.3.jar:5.4.3]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

2018-12-08 13:22:14.624  INFO 5172 --- [cTaskExecutor-1] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: [127.0.0.1:15672]
2018-12-08 13:22:14.625  INFO 5172 --- [cTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@bb095: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2018-12-08 13:22:19.624  INFO 5172 --- [cTaskExecutor-2] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: [127.0.0.1:15672]
2018-12-08 13:22:19.625 ERROR 5172 --- [cTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer : Failed to check/redeclare auto-delete queue(s).

org.springframework.amqp.AmqpIOException: java.io.IOException
	at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:509) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:684) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:214) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1961) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1935) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1916) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:393) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1722) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1026) [spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]
Caused by: java.io.IOException: null
	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:126) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:122) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:373) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1104) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1054) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:994) ~[amqp-client-5.4.3.jar:5.4.3]
	at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:462) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	... 9 common frames omitted
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error
	at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:494) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:315) ~[amqp-client-5.4.3.jar:5.4.3]
	... 13 common frames omitted
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106

最后在网上发现资料解说:

地址:http://www.cnblogs.com/fightfordream/p/9048905.html

这个BUG我是通过修改application.properties中的spring.rabbitmq.port修复好的,这里我一开始使用了http的端口15672,发生了上述异常。后面改成了5672可以成功连接。

映射2个端口:15672是Web管理界面的端口;5672是MQ访问的端口。

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)
  • 1
  • 2
  • 3

无法自动创建队列

无法创建队列,或者找不到声明的队列。

@Bean
public Queue queue() {
    return new Queue(queue_name, true);
}
  • 1
  • 2
  • 3
  • 4

这里是忘了注入队列的Bean了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/1018330
推荐阅读
相关标签
  

闽ICP备14008679号