sunhk commented on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-939230733


   > 
   > 
   > 
如果启动异常会调用spring的销毁方法,那么Dubbo就可以接收到销毁的通知。通过org.apache.dubbo.config.spring.context.DubboDeployApplicationListener会结束掉这个线程。按道理应该会中止这个线程,所以能否提供能复现的demo。
   
   
抱歉问题描述不够严谨,解决方案也过于想当然了,有违此类初衷。今天又重新跟踪了一下,发现简单的dubbo-springboot使用并不会发生此问题,之所以会出现程序报错后进程没有停止的现象是因为我的项目中引入了spring-cloud组件,BootstrapApplicationListener中进行了额外了SpringApplication对象初始化过程,发生了ApplicationReadyEvent事件,导致AwaitingNonWebApplicationListener中的await方法被调用,使线程池中线程提前初始化,#8133
 也提到await方法提前调用,可能有相似之处,复现代码如下:
   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>
       <groupId>com.example</groupId>
       <artifactId>dubbo-spring</artifactId>
       <version>0.0.1-SNAPSHOT</version>
   
       <dependencies>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter</artifactId>
               <version>2.3.10.RELEASE</version>
           </dependency>
           <dependency>
               <groupId>org.apache.dubbo</groupId>
               <artifactId>dubbo-spring-boot-starter</artifactId>
               <version>3.0.3</version>
           </dependency>
           <dependency>
               <groupId>org.springframework.cloud</groupId>
               <artifactId>spring-cloud-context</artifactId>
               <version>2.2.8.RELEASE</version>
           </dependency>
       </dependencies>
   </project>
   ```
   
   application.yml
   ```
   dubbo:
     application:
       name: demo
     registry:
       protocol: multicast
       address: 224.5.6.7:1234
   string: error
   ```
   
   Application.java
   ```
   package com.example;
   
   import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
   import org.springframework.beans.factory.annotation.Value;
   import org.springframework.boot.SpringApplication;
   import org.springframework.boot.autoconfigure.SpringBootApplication;
   
   @SpringBootApplication
   //@EnableDubbo
   public class Application {
       @Value("${string}")
       private Integer value;
   
       public static void main(String[] args) {
           SpringApplication.run(Application.class, args);
       }
   }
   ```
   
是否使用@EnableDubbo并不影响此现象发生,是否考虑将AwaitingNonWebApplicationListener的加载像DubboDeployApplicationListener一样与@EnableDubbo关联起来,而不是放在spring.factories中,从而保证只有初始化dubbo环境的SpringApplication才会调用此Listener
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to