我有一个使用spring AMPQ的春季启动项目,主机没有问题,我只想在本地禁用无限重试连接,或者至少增加重试间隔时间。
2022-08-16 13:56:42.849 INFO 40008 --- [ main] o.s.c.s.binder.DefaultBinderFactory : Creating binder: rabbit
2022-08-16 13:56:43.165 INFO 40008 --- [ main] o.s.c.s.binder.DefaultBinderFactory : Caching the binder: rabbit
2022-08-16 13:56:43.165 INFO 40008 --- [ main] o.s.c.s.binder.DefaultBinderFactory : Retrieving cached binder: rabbit
2022-08-16 13:56:43.271 INFO 40008 --- [ main] c.s.b.r.p.RabbitExchangeQueueProvisioner : declaring queue for inbound: springCloudBus.anonymous.4IzJRJtxT1afyh0KS7yI5w, bound to: springCloudBus
2022-08-16 13:56:43.274 INFO 40008 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:56:47.371 INFO 40008 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:56:51.460 INFO 40008 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:56:55.627 INFO 40008 --- [ main] o.s.c.stream.binder.BinderErrorChannel : Channel 'springCloudBus.anonymous.4IzJRJtxT1afyh0KS7yI5w.errors' has 1 subscriber(s).
2022-08-16 13:56:55.628 INFO 40008 --- [ main] o.s.c.stream.binder.BinderErrorChannel : Channel 'springCloudBus.anonymous.4IzJRJtxT1afyh0KS7yI5w.errors' has 2 subscriber(s).
2022-08-16 13:56:55.630 INFO 40008 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:56:59.673 INFO 40008 --- [ main] o.s.a.r.l.SimpleMessageListenerContainer : Broker not available; cannot force queue declarations during start: java.net.ConnectException: Connection refused: connect
2022-08-16 13:56:59.679 INFO 40008 --- [1afyh0KS7yI5w-1] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:57:03.931 INFO 40008 --- [ main] o.s.i.a.i.AmqpInboundChannelAdapter : started bean 'inbound.springCloudBus.anonymous.4IzJRJtxT1afyh0KS7yI5w'
2022-08-16 13:57:04.059 INFO 40008 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-08-16 13:57:05.110 INFO 40008 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2022-08-16 13:57:05.140 INFO 40008 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2022-08-16 13:57:05.255 INFO 40008 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2022-08-16 13:57:05.362 INFO 40008 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: getApplicationFeedbackUsingGET_1
2022-08-16 13:57:05.404 INFO 40008 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: getListUsingGET_1
2022-08-16 13:57:05.760 INFO 40008 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel springCloudBus.anonymous.4IzJRJtxT1afyh0KS7yI5w.errors
2022-08-16 13:57:06.992 INFO 40008 --- [22)-19.3.148.44] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:57:07.156 INFO 40008 --- [21)-19.3.148.44] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-08-16 13:57:07.156 INFO 40008 --- [21)-19.3.148.44] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-08-16 13:57:07.159 INFO 40008 --- [21)-19.3.148.44] o.s.web.servlet.DispatcherServlet : Completed initialization in 3 ms
2022-08-16 13:57:09.206 WARN 40008 --- [1afyh0KS7yI5w-1] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
2022-08-16 13:57:09.209 INFO 40008 --- [1afyh0KS7yI5w-1] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@1727d525: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 13:57:11.086 INFO 40008 --- [1afyh0KS7yI5w-2] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:57:11.125 WARN 40008 --- [22)-19.3.148.44] o.s.b.a.amqp.RabbitHealthIndicator : Rabbit health check failed
org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:61) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:602) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:724) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:252) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2163) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2136) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2116) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.getVersion(RabbitHealthIndicator.java:49) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.doHealthCheck(RabbitHealthIndicator.java:44) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:82) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthIndicator.getHealth(HealthIndicator.java:37) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:71) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:39) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:99) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getAggregateHealth(HealthEndpointSupport.java:110) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:96) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:74) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:61) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:65) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:55) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282) ~[spring-core-5.3.10.jar:5.3.10]
at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:74) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:121) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:96) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809) ~[na:na]
at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) ~[na:na]
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466) ~[na:na]
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307) ~[na:na]
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399) ~[na:na]
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) ~[na:na]
at java.base/jdk.internal.reflect.GeneratedMethodAccessor157.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359) ~[na:na]
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) ~[na:na]
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) ~[na:na]
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562) ~[na:na]
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796) ~[na:na]
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: java.net.ConnectException: Connection refused: connect
at java.base/java.net.PlainSocketImpl.waitForConnect(Native Method) ~[na:na]
at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:107) ~[na:na]
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) ~[na:na]
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) ~[na:na]
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) ~[na:na]
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403) ~[na:na]
at java.base/java.net.Socket.connect(Socket.java:609) ~[na:na]
at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60) ~[amqp-client-5.12.0.jar:5.12.0]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1220) ~[amqp-client-5.12.0.jar:5.12.0]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1170) ~[amqp-client-5.12.0.jar:5.12.0]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connectAddresses(AbstractConnectionFactory.java:640) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connect(AbstractConnectionFactory.java:615) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:565) ~[spring-rabbit-2.3.10.jar:2.3.10]
... 49 common frames omitted
2022-08-16 13:57:15.193 INFO 40008 --- [22)-19.3.148.44] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:57:19.294 WARN 40008 --- [22)-19.3.148.44] o.s.b.a.amqp.RabbitHealthIndicator : Rabbit health check failed
org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:61) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:602) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:724) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:252) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2163) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2136) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2116) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.getVersion(RabbitHealthIndicator.java:49) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.doHealthCheck(RabbitHealthIndicator.java:44) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:82) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthIndicator.getHealth(HealthIndicator.java:37) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:71) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:39) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:99) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getAggregateHealth(HealthEndpointSupport.java:110) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:96) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getAggregateHealth(HealthEndpointSupport.java:110) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:96) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:74) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:61) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:65) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:55) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282) ~[spring-core-5.3.10.jar:5.3.10]
at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:74) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:121) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:96) ~[spring-boot-actuator-2.5.5.jar:2.5.5]
at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809) ~[na:na]
at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) ~[na:na]
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466) ~[na:na]
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307) ~[na:na]
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399) ~[na:na]
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) ~[na:na]
at java.base/jdk.internal.reflect.GeneratedMethodAccessor157.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359) ~[na:na]
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) ~[na:na]
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) ~[na:na]
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562) ~[na:na]
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796) ~[na:na]
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: java.net.ConnectException: Connection refused: connect
at java.base/java.net.PlainSocketImpl.waitForConnect(Native Method) ~[na:na]
at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:107) ~[na:na]
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) ~[na:na]
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) ~[na:na]
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) ~[na:na]
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403) ~[na:na]
at java.base/java.net.Socket.connect(Socket.java:609) ~[na:na]
at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60) ~[amqp-client-5.12.0.jar:5.12.0]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1220) ~[amqp-client-5.12.0.jar:5.12.0]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1170) ~[amqp-client-5.12.0.jar:5.12.0]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connectAddresses(AbstractConnectionFactory.java:640) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connect(AbstractConnectionFactory.java:615) ~[spring-rabbit-2.3.10.jar:2.3.10]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:565) ~[spring-rabbit-2.3.10.jar:2.3.10]
... 51 common frames omitted
2022-08-16 13:57:20.269 WARN 40008 --- [1afyh0KS7yI5w-2] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
2022-08-16 13:57:20.269 INFO 40008 --- [1afyh0KS7yI5w-2] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@92cb521: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 13:57:20.270 INFO 40008 --- [1afyh0KS7yI5w-3] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:57:29.439 WARN 40008 --- [1afyh0KS7yI5w-3] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
2022-08-16 13:57:29.439 INFO 40008 --- [1afyh0KS7yI5w-3] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@3fa71956: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 13:57:29.440 INFO 40008 --- [1afyh0KS7yI5w-4] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 13:57:38.593 WARN 40008 --- [1afyh0KS7yI5w-4] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
2022-08-16 13:57:38.593 INFO 40008 --- [1afyh0KS7yI5w-4] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@54a50d69: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 13:57:38.593 INFO 40008 --- [1afyh0KS7yI5w-5] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
试图增加后退间隔似乎没有任何作用。
@Configuration
@EnableRabbit
@Profile("!cloud")
public class LocalConfiguration
{
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory)
{
SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory = new SimpleRabbitListenerContainerFactory();
simpleRabbitListenerContainerFactory.setConnectionFactory(connectionFactory);
ExponentialBackOff exponentialBackOff = new ExponentialBackOff(100, 3.0);
simpleRabbitListenerContainerFactory.setRecoveryBackOff(exponentialBackOff);
return simpleRabbitListenerContainerFactory;
}
}
有没有办法增加超时或禁用持续重试?
我刚刚复制了你的工厂,它完全按照预期工作:
2022-08-16 14:03:06.012 WARN 97694 --- [ 127.0.0.1:5672] c.r.c.impl.ForgivingExceptionHandler : An unexpected connection driver error occurred (Exception message: Connection reset)
2022-08-16 14:03:06.499 INFO 97694 --- [ntContainer#0-1] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@30c31dd7: tags=[[amq.ctag-v4isXkIaMAAe_NHmUnHMzg]], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1), conn: Proxy@24be2d9c Shared Rabbit Connection: SimpleConnection@41200e0c [delegate=amqp://guest@127.0.0.1:5672/, localPort= 61142], acknowledgeMode=AUTO local queue size=0
2022-08-16 14:03:06.502 INFO 97694 --- [ntContainer#0-2] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 14:03:06.712 WARN 97694 --- [ntContainer#0-2] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2022-08-16 14:03:06.712 INFO 97694 --- [ntContainer#0-2] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@2a884e96: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 14:03:06.714 INFO 97694 --- [ntContainer#0-3] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 14:03:07.125 WARN 97694 --- [ntContainer#0-3] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2022-08-16 14:03:07.126 INFO 97694 --- [ntContainer#0-3] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@28a5e291: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 14:03:07.170 INFO 97694 --- [ntContainer#0-4] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 14:03:08.186 WARN 97694 --- [ntContainer#0-4] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2022-08-16 14:03:08.186 INFO 97694 --- [ntContainer#0-4] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@7e1e240: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 14:03:08.187 INFO 97694 --- [ntContainer#0-5] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 14:03:11.022 WARN 97694 --- [ntContainer#0-5] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2022-08-16 14:03:11.023 INFO 97694 --- [ntContainer#0-5] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@5285c94: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 14:03:11.025 INFO 97694 --- [ntContainer#0-6] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 14:03:19.328 WARN 97694 --- [ntContainer#0-6] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2022-08-16 14:03:19.329 INFO 97694 --- [ntContainer#0-6] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@7500ff90: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 14:03:19.330 INFO 97694 --- [ntContainer#0-7] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 14:03:43.661 WARN 97694 --- [ntContainer#0-7] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2022-08-16 14:03:43.662 INFO 97694 --- [ntContainer#0-7] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@70a5660e: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 14:03:43.664 INFO 97694 --- [ntContainer#0-8] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-16 14:04:13.679 WARN 97694 --- [ntContainer#0-8] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2022-08-16 14:04:13.680 INFO 97694 --- [ntContainer#0-8] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@a7d0a48: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-08-16 14:04:13.682 INFO 97694 --- [ntContainer#0-9] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
最后一次重试间隔30秒(这是ExponentialBackOff
的默认最大值(100ms、300ms、900ms、2.7s、8s、24s、30s(。
有些重试与侦听器容器无关,而是尝试连接的RabbitHealthIndicator
。
您的容器重试次数似乎是9秒的FixedBackOff
,因此有些内容不符合要求。