无法使用 Spring Boot 2.1.5、Spring Cloud Stream Greenwich.SR1 和 RocketMQ 0.9.0 停止 bean 'inputBindingLifecycle'
Failed to stop bean 'inputBindingLifecycle' with Spring Boot 2.1.5, Spring Cloud Stream Greenwich.SR1 and RocketMQ 0.9.0
我看过类似的问题,但它是针对旧版本的。不确定冲突版本对我来说是什么,以及我需要使用什么。
我使用 Spring Initializr 来创建我的项目,遵循 SCS 参考 Quick Start。这让我设置了当前版本(2.1.5,Greenwich.SR1)。
我手动添加的唯一依赖项是 RocketMQ,因为 Spring Initializr 找不到它。这是我的 pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
<version>0.9.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
当我尝试关闭应用程序时出现问题,每次关闭该过程需要将近一分钟。这是我关闭应用程序时的完整堆栈跟踪:
Failed to stop bean 'inputBindingLifecycle'
java.lang.IllegalStateException: Shutdown in progress at
java.lang.ApplicationShutdownHooks.remove(ApplicationShutdownHooks.java:82)
~[na:1.8.0_181] at
java.lang.Runtime.removeShutdownHook(Runtime.java:239) ~[na:1.8.0_181]
at
org.apache.rocketmq.client.trace.AsyncTraceDispatcher.removeShutdownHook(AsyncTraceDispatcher.java:210)
~[rocketmq-client-4.4.0.jar:4.4.0] at
org.apache.rocketmq.client.trace.AsyncTraceDispatcher.shutdown(AsyncTraceDispatcher.java:183)
~[rocketmq-client-4.4.0.jar:4.4.0] at
org.apache.rocketmq.client.consumer.DefaultMQPushConsumer.shutdown(DefaultMQPushConsumer.java:598)
~[rocketmq-client-4.4.0.jar:4.4.0] at
org.springframework.cloud.stream.binder.rocketmq.consuming.RocketMQListenerBindingContainer.stop(RocketMQListenerBindingContainer.java:175)
~[spring-cloud-stream-binder-rocketmq-0.9.0.RELEASE.jar:0.9.0.RELEASE]
at
org.springframework.cloud.stream.binder.rocketmq.integration.RocketMQInboundChannelAdapter.doStop(RocketMQInboundChannelAdapter.java:128)
~[spring-cloud-stream-binder-rocketmq-0.9.0.RELEASE.jar:0.9.0.RELEASE]
at
org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:173)
~[spring-integration-core-5.1.3.RELEASE.jar:5.1.3.RELEASE] at
org.springframework.cloud.stream.binder.DefaultBinding.stop(DefaultBinding.java:127)
~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at
org.springframework.cloud.stream.binder.DefaultBinding.unbind(DefaultBinding.java:159)
~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at
org.springframework.cloud.stream.binding.BindingService.unbindConsumers(BindingService.java:303)
~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at
org.springframework.cloud.stream.binding.BindableProxyFactory.unbindInputs(BindableProxyFactory.java:307)
~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at
org.springframework.cloud.stream.binding.InputBindingLifecycle.doStopWithBindable(InputBindingLifecycle.java:66)
~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at
java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:608)
~[na:1.8.0_181] at
org.springframework.cloud.stream.binding.AbstractBindingLifecycle.stop(AbstractBindingLifecycle.java:56)
~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at
org.springframework.cloud.stream.binding.InputBindingLifecycle.stop(InputBindingLifecycle.java:34)
~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at
org.springframework.cloud.stream.binding.AbstractBindingLifecycle.stop(AbstractBindingLifecycle.java:73)
~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at
org.springframework.cloud.stream.binding.InputBindingLifecycle.stop(InputBindingLifecycle.java:34)
~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at
org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:238)
[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at
org.springframework.context.support.DefaultLifecycleProcessor.access0(DefaultLifecycleProcessor.java:53)
[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at
org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:377)
[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at
org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:210)
[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at
org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:128)
[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1018)
[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.run(AbstractApplicationContext.java:945)
[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] ```
解决方案是对 RocketMQ 绑定器使用版本 0.2。1.RELEASE:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
<version>0.2.1.RELEASE</version>
</dependency>
我看过类似的问题
我使用 Spring Initializr 来创建我的项目,遵循 SCS 参考 Quick Start。这让我设置了当前版本(2.1.5,Greenwich.SR1)。
我手动添加的唯一依赖项是 RocketMQ,因为 Spring Initializr 找不到它。这是我的 pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
<version>0.9.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
当我尝试关闭应用程序时出现问题,每次关闭该过程需要将近一分钟。这是我关闭应用程序时的完整堆栈跟踪:
Failed to stop bean 'inputBindingLifecycle'
java.lang.IllegalStateException: Shutdown in progress at java.lang.ApplicationShutdownHooks.remove(ApplicationShutdownHooks.java:82) ~[na:1.8.0_181] at java.lang.Runtime.removeShutdownHook(Runtime.java:239) ~[na:1.8.0_181] at org.apache.rocketmq.client.trace.AsyncTraceDispatcher.removeShutdownHook(AsyncTraceDispatcher.java:210) ~[rocketmq-client-4.4.0.jar:4.4.0] at org.apache.rocketmq.client.trace.AsyncTraceDispatcher.shutdown(AsyncTraceDispatcher.java:183) ~[rocketmq-client-4.4.0.jar:4.4.0] at org.apache.rocketmq.client.consumer.DefaultMQPushConsumer.shutdown(DefaultMQPushConsumer.java:598) ~[rocketmq-client-4.4.0.jar:4.4.0] at org.springframework.cloud.stream.binder.rocketmq.consuming.RocketMQListenerBindingContainer.stop(RocketMQListenerBindingContainer.java:175) ~[spring-cloud-stream-binder-rocketmq-0.9.0.RELEASE.jar:0.9.0.RELEASE] at org.springframework.cloud.stream.binder.rocketmq.integration.RocketMQInboundChannelAdapter.doStop(RocketMQInboundChannelAdapter.java:128) ~[spring-cloud-stream-binder-rocketmq-0.9.0.RELEASE.jar:0.9.0.RELEASE] at org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:173) ~[spring-integration-core-5.1.3.RELEASE.jar:5.1.3.RELEASE] at org.springframework.cloud.stream.binder.DefaultBinding.stop(DefaultBinding.java:127) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.cloud.stream.binder.DefaultBinding.unbind(DefaultBinding.java:159) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.cloud.stream.binding.BindingService.unbindConsumers(BindingService.java:303) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.cloud.stream.binding.BindableProxyFactory.unbindInputs(BindableProxyFactory.java:307) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.cloud.stream.binding.InputBindingLifecycle.doStopWithBindable(InputBindingLifecycle.java:66) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:608) ~[na:1.8.0_181] at org.springframework.cloud.stream.binding.AbstractBindingLifecycle.stop(AbstractBindingLifecycle.java:56) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.cloud.stream.binding.InputBindingLifecycle.stop(InputBindingLifecycle.java:34) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.cloud.stream.binding.AbstractBindingLifecycle.stop(AbstractBindingLifecycle.java:73) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.cloud.stream.binding.InputBindingLifecycle.stop(InputBindingLifecycle.java:34) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:238) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.access0(DefaultLifecycleProcessor.java:53) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:377) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:210) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:128) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1018) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.run(AbstractApplicationContext.java:945) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] ```
解决方案是对 RocketMQ 绑定器使用版本 0.2。1.RELEASE:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
<version>0.2.1.RELEASE</version>
</dependency>