java - SpringBoot rabbit connection timeout issue -
my spring boot application throws connection timeout error, , never able connect. other interesting problem see is, never picking connection timeout property defined in spring app properties.
org.springframework.amqp.amqptimeoutexception: java.util.concurrent.timeoutexception @ org.springframework.amqp.rabbit.support.rabbitexceptiontranslator.convertrabbitaccessexception(rabbitexceptiontranslator.java:74) ~[spring-rabbit-1.6.7.release.jar:na] @ org.springframework.amqp.rabbit.connection.abstractconnectionfactory.createbareconnection(abstractconnectionfactory.java:309) ~[spring-rabbit-1.6.7.release.jar:na] @ org.springframework.amqp.rabbit.connection.cachingconnectionfactory.createconnection(cachingconnectionfactory.java:577) ~[spring-rabbit-1.6.7.release.jar:na] @ org.springframework.amqp.rabbit.core.rabbittemplate.doexecute(rabbittemplate.java:1431) ~[spring-rabbit-1.6.7.release.jar:na] @ org.springframework.amqp.rabbit.core.rabbittemplate.execute(rabbittemplate.java:1412) ~[spring-rabbit-1.6.7.release.jar:na] @ org.springframework.amqp.rabbit.core.rabbittemplate.execute(rabbittemplate.java:1388) ~[spring-rabbit-1.6.7.release.jar:na] @ org.springframework.amqp.rabbit.core.rabbitadmin.getqueueproperties(rabbitadmin.java:336) ~[spring-rabbit-1.6.7.release.jar:na] @ org.springframework.amqp.rabbit.listener.simplemessagelistenercontainer.redeclareelementsifnecessary(simplemessagelistenercontainer.java:1123) [spring-rabbit-1.6.7.release.jar:na] @ org.springframework.amqp.rabbit.listener.simplemessagelistenercontainer.access$800(simplemessagelistenercontainer.java:98) [spring-rabbit-1.6.7.release.jar:na] @ org.springframework.amqp.rabbit.listener.simplemessagelistenercontainer$asyncmessageprocessingconsumer.run(simplemessagelistenercontainer.java:1329) [spring-rabbit-1.6.7.release.jar:na] @ java.lang.thread.run(thread.java:745) [na:1.8.0_91] caused by: java.util.concurrent.timeoutexception: null @ com.rabbitmq.utility.blockingcell.get(blockingcell.java:76) ~[amqp-client-3.6.5.jar:na] @ com.rabbitmq.utility.blockingcell.uninterruptibleget(blockingcell.java:110) ~[amqp-client-3.6.5.jar:na] @ com.rabbitmq.utility.blockingvalueorexception.uninterruptiblegetvalue(blockingvalueorexception.java:36) ~[amqp-client-3.6.5.jar:na] @ com.rabbitmq.client.impl.amqchannel$blockingrpccontinuation.getreply(amqchannel.java:366) ~[amqp-client-3.6.5.jar:na] @ com.rabbitmq.client.impl.amqconnection.start(amqconnection.java:292) ~[amqp-client-3.6.5.jar:na] @ com.rabbitmq.client.connectionfactory.newconnection(connectionfactory.java:824) ~[amqp-client-3.6.5.jar:na] @ com.rabbitmq.client.connectionfactory.newconnection(connectionfactory.java:736) ~[amqp-client-3.6.5.jar:na] @ org.springframework.amqp.rabbit.connection.abstractconnectionfactory.createbareconnection(abstractconnectionfactory.java:293) ~[spring-rabbit-1.6.7.release.jar:na] ... 9 common frames omitted
here java config,
@configuration @enablerabbit public class rabbitconfig { private final string exchange; private final string queuename; public rabbitconfig( @value("${exchange.name}") string exchange, @value("${queue.name}") string queue) { this.exchange= exchange; this.queuename=queue; } @bean queue queue() { return new queue(queuename, true); } @bean directexchange exchange() { return new directexchange(queuename); } @bean binding binding(queue queue, directexchange exchange) { return bindingbuilder.bind(queue).to(exchange).with(queuename); } @bean simplemessagelistenercontainer container(rabbitadmin admin,cachingconnectionfactory connectionfactory) { simplemessagelistenercontainer container = new simplemessagelistenercontainer(); connectionfactory.setclosetimeout(10000); container.setqueuenames(queuename); container.setconnectionfactory(connectionfactory); //container.setmessagelistener(listeneradapter); return container; } // @bean // messagelisteneradapter listeneradapter(receiver receiver) { // return new messagelisteneradapter(receiver, "receivemessage"); // } @bean public rabbitadmin admin(connectionfactory connectionfactory) { return new rabbitadmin(connectionfactory); } }
and spring application properties like,
spring.rabbitmq.host = 127.0.0.1 spring.rabbitmq.port = 15672 spring.rabbitmq.username = guest spring.rabbitmq.password = guest exchange.name=myexchange queue.name=myqueue spring.rabbitmq.cache.connection.mode=connection spring.rabbitmq.cache.channel.size=50 spring.rabbitmq.cache.channel.checkout-timeout= 10000
rabbit , running on 127.0.0.1 on port 15672, app never able connect.
by default, amqp port 5672. port 15672 shows web ui (admin console). if you're using default setup, adjust
spring.rabbitmq.port = 5672
Comments
Post a Comment