[apache/dubbo]dubbo应用自动关闭

2024-05-24 57 views
4
Environment
  • Dubbo version: 3.2.0-beta.4
  • Operating System version: macos13
  • Java version: jdk17

接入nacos作为配置中心,引入该包,使用bootstrap.yml作为优先配置文件时,应用启动后会自动关闭。 当排除该包时,应用可用

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bootstrap</artifactId>
        <version>3.1.5</version>
 </dependency>
2023-02-06T16:49:04.724+08:00  INFO 15550 --- [           main] .c.m.ConfigurableMetadataServiceExporter :  [DUBBO] The MetadataService exports urls : [dubbo://192.168.5.6:20881/org.apache.dubbo.metadata.MetadataService?anyhost=true&application=cynray-micro-user&background=false&bind.ip=192.168.5.6&bind.port=20881&corethreads=2&delay=0&deprecated=false&dubbo=2.0.2&dynamic=true&executes=100&executor-management-mode=default&file.cache=true&generic=false&getAndListenInstanceMetadata.1.callback=true&getAndListenInstanceMetadata.return=true&getAndListenInstanceMetadata.sent=true&group=cynray-micro-user&interface=org.apache.dubbo.metadata.MetadataService&methods=exportInstanceMetadata,getAndListenInstanceMetadata,getExportedServiceURLs,getExportedURLs,getExportedURLs,getExportedURLs,getExportedURLs,getExportedURLs,getInstanceMetadataChangedListenerMap,getMetadataInfo,getMetadataInfos,getMetadataURL,getServiceDefinition,getServiceDefinition,getSubscribedURLs,isMetadataService,serviceName,toSortedStrings,toSortedStrings,version&pid=15550&prefer.serialization=fastjson2&qos.enable=false&register=false&release=3.2.0-beta.4&revision=3.2.0-beta.4&serialization=fastjson2&service-name-mapping=true&side=provider&threadpool=cached&threads=100&timestamp=1675673344678&version=1.0.0], dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.725+08:00  INFO 15550 --- [           main] o.a.d.r.c.m.ServiceInstanceMetadataUtils :  [DUBBO] Start registering instance address to registry., dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.736+08:00  INFO 15550 --- [           main] org.apache.dubbo.metadata.MetadataInfo   :  [DUBBO] metadata revision changed: null -> d411da83262d2359301e9124793aedd3, app: cynray-micro-user, services: 2, dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.903+08:00  INFO 15550 --- [           main] o.a.d.c.d.DefaultApplicationDeployer     :  [DUBBO] Dubbo Application[1.1](cynray-micro-user) is ready., dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.905+08:00  INFO 15550 --- [           main] c.c.micro.user.app.UserAppApplication    : Started UserAppApplication in 6.088 seconds (process running for 6.675)
2023-02-06T16:49:04.906+08:00  INFO 15550 --- [           main] c.c.p.s.micro.MicroApplicationRunner     : 

----------------------------------------------------------
cynray-micro-user
----------------------------------------------------------
    Rpc:    dubbo://127.0.0.1:20881
----------------------------------------------------------

2023-02-06T16:49:04.908+08:00  INFO 15550 --- [           main] c.a.nacos.client.config.impl.CacheData   : nacos.cache.data.init.snapshot = true 
2023-02-06T16:49:04.909+08:00  INFO 15550 --- [           main] c.a.n.client.config.impl.ClientWorker    : [fixed-cynray-dev-10.233.19.87_8848] [subscribe] zookeeper.yaml+middleware+cynray-dev
2023-02-06T16:49:04.916+08:00  INFO 15550 --- [           main] c.a.nacos.client.config.impl.CacheData   : [fixed-cynray-dev-10.233.19.87_8848] [add-listener] ok, tenant=cynray-dev, dataId=zookeeper.yaml, group=middleware, cnt=1
2023-02-06T16:49:04.916+08:00  INFO 15550 --- [           main] c.a.c.n.refresh.NacosContextRefresher    : [Nacos Config] Listening config: dataId=zookeeper.yaml, group=middleware
2023-02-06T16:49:04.916+08:00  INFO 15550 --- [           main] c.a.n.client.config.impl.ClientWorker    : [fixed-cynray-dev-10.233.19.87_8848] [subscribe] postgresql.yaml+middleware+cynray-dev
2023-02-06T16:49:04.916+08:00  INFO 15550 --- [           main] c.a.nacos.client.config.impl.CacheData   : [fixed-cynray-dev-10.233.19.87_8848] [add-listener] ok, tenant=cynray-dev, dataId=postgresql.yaml, group=middleware, cnt=1
2023-02-06T16:49:04.916+08:00  INFO 15550 --- [           main] c.a.c.n.refresh.NacosContextRefresher    : [Nacos Config] Listening config: dataId=postgresql.yaml, group=middleware
2023-02-06T16:49:04.917+08:00  INFO 15550 --- [           main] c.a.n.client.config.impl.ClientWorker    : [fixed-cynray-dev-10.233.19.87_8848] [subscribe] cynray-micro-user.yaml+user-center+cynray-dev
2023-02-06T16:49:04.917+08:00  INFO 15550 --- [           main] c.a.nacos.client.config.impl.CacheData   : [fixed-cynray-dev-10.233.19.87_8848] [add-listener] ok, tenant=cynray-dev, dataId=cynray-micro-user.yaml, group=user-center, cnt=1
2023-02-06T16:49:04.917+08:00  INFO 15550 --- [           main] c.a.c.n.refresh.NacosContextRefresher    : [Nacos Config] Listening config: dataId=cynray-micro-user.yaml, group=user-center
2023-02-06T16:49:04.917+08:00  INFO 15550 --- [           main] c.a.n.client.config.impl.ClientWorker    : [fixed-cynray-dev-10.233.19.87_8848] [subscribe] cynray-micro-user+user-center+cynray-dev
2023-02-06T16:49:04.917+08:00  INFO 15550 --- [           main] c.a.nacos.client.config.impl.CacheData   : [fixed-cynray-dev-10.233.19.87_8848] [add-listener] ok, tenant=cynray-dev, dataId=cynray-micro-user, group=user-center, cnt=1
2023-02-06T16:49:04.917+08:00  INFO 15550 --- [           main] c.a.c.n.refresh.NacosContextRefresher    : [Nacos Config] Listening config: dataId=cynray-micro-user, group=user-center
2023-02-06T16:49:04.919+08:00  INFO 15550 --- [bboShutdownHook] o.apache.dubbo.config.DubboShutdownHook  :  [DUBBO] Run shutdown hook now., dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.919+08:00  WARN 15550 --- [       Thread-7] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Start destroying Publisher
2023-02-06T16:49:04.919+08:00  WARN 15550 --- [       Thread-1] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Start destroying common HttpClient
2023-02-06T16:49:04.919+08:00  WARN 15550 --- [       Thread-7] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Destruction of the end
2023-02-06T16:49:04.919+08:00  INFO 15550 --- [bboShutdownHook] o.apache.dubbo.config.DubboShutdownHook  :  [DUBBO] Waiting for modules managed by Spring to be shut down., dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.919+08:00  WARN 15550 --- [       Thread-1] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Destruction of the end
2023-02-06T16:49:04.920+08:00  INFO 15550 --- [ionShutdownHook] o.a.d.c.deploy.DefaultModuleDeployer     :  [DUBBO] Dubbo Module[1.1.1] is stopping., dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.922+08:00  INFO 15550 --- [ionShutdownHook] o.a.d.r.zookeeper.ZookeeperRegistry      :  [DUBBO] Unregister: dubbo://192.168.5.6:20881/com.cynray.micro.user.api.user.UserProvider?anyhost=true&application=cynray-micro-user&background=false&deprecated=false&dubbo=2.0.2&dynamic=true&executor-management-mode=default&file.cache=true&generic=false&interface=com.cynray.micro.user.api.user.UserProvider&methods=add,add,addAsync&pid=15550&prefer.serialization=fastjson2&release=3.2.0-beta.4&serialization=fastjson2&service-name-mapping=true&side=provider&timestamp=1675673343779, dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.932+08:00  INFO 15550 --- [bboShutdownHook] o.apache.dubbo.config.DubboShutdownHook  :  [DUBBO] Dubbo shuts down application after Spring fails to do in time or doesn't do it completely., dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.932+08:00  INFO 15550 --- [bboShutdownHook] o.apache.dubbo.rpc.model.FrameworkModel  :  [DUBBO] Reset global default application from Dubbo Application[1.1](cynray-micro-user) to null, dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:04.932+08:00  INFO 15550 --- [bboShutdownHook] o.a.d.c.d.DefaultApplicationDeployer     :  [DUBBO] Dubbo Application[1.1](cynray-micro-user) is stopping., dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:05.024+08:00  INFO 15550 --- [ionShutdownHook] o.a.d.r.zookeeper.ZookeeperRegistry      :  [DUBBO] Unsubscribe: provider://192.168.5.6:20881/com.cynray.micro.user.api.user.UserProvider?anyhost=true&application=cynray-micro-user&background=false&bind.ip=192.168.5.6&bind.port=20881&category=configurators&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&executor-management-mode=default&file.cache=true&generic=false&interface=com.cynray.micro.user.api.user.UserProvider&methods=add,add,addAsync&pid=15550&prefer.serialization=fastjson2&qos.enable=false&release=3.2.0-beta.4&serialization=fastjson2&service-name-mapping=true&side=provider&timestamp=1675673343779, dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:05.025+08:00  INFO 15550 --- [ionShutdownHook] o.a.d.r.zookeeper.ZookeeperRegistry      :  [DUBBO] Unregister: dubbo://192.168.5.6:20881/com.cynray.micro.user.api.user.UserQueryProvider?anyhost=true&application=cynray-micro-user&background=false&deprecated=false&dubbo=2.0.2&dynamic=true&executor-management-mode=default&file.cache=true&generic=false&interface=com.cynray.micro.user.api.user.UserQueryProvider&methods=getById,getById,getByIdAsync,getRoleList,getRoleList,getRoleListAsync&pid=15550&prefer.serialization=fastjson2&release=3.2.0-beta.4&serialization=fastjson2&service-name-mapping=true&side=provider&timestamp=1675673344473, dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:05.039+08:00  INFO 15550 --- [bboShutdownHook] o.a.d.rpc.protocol.dubbo.DubboProtocol   :  [DUBBO] Destroying protocol [DubboProtocol] ..., dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:05.039+08:00  INFO 15550 --- [bboShutdownHook] o.a.d.rpc.protocol.dubbo.DubboProtocol   :  [DUBBO] Closing dubbo server: /192.168.5.6:20881, dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:05.040+08:00  INFO 15550 --- [bboShutdownHook] o.a.d.remoting.transport.AbstractServer  :  [DUBBO] Close NettyServer bind /0.0.0.0:20881, export /192.168.5.6:20881, dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:05.073+08:00  INFO 15550 --- [ionShutdownHook] o.a.d.r.zookeeper.ZookeeperRegistry      :  [DUBBO] Unsubscribe: provider://192.168.5.6:20881/com.cynray.micro.user.api.user.UserQueryProvider?anyhost=true&application=cynray-micro-user&background=false&bind.ip=192.168.5.6&bind.port=20881&category=configurators&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&executor-management-mode=default&file.cache=true&generic=false&interface=com.cynray.micro.user.api.user.UserQueryProvider&methods=getById,getById,getByIdAsync,getRoleList,getRoleList,getRoleListAsync&pid=15550&prefer.serialization=fastjson2&qos.enable=false&release=3.2.0-beta.4&serialization=fastjson2&service-name-mapping=true&side=provider&timestamp=1675673344473, dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:05.074+08:00  INFO 15550 --- [ionShutdownHook] o.a.d.c.deploy.DefaultModuleDeployer     :  [DUBBO] Dubbo Module[1.1.1] has stopped., dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
2023-02-06T16:49:05.075+08:00  INFO 15550 --- [ionShutdownHook] o.a.d.c.s.c.DubboSpringInitializer       :  [DUBBO] Unbind Dubbo Module[1.1.1] from spring container: org.springframework.beans.factory.support.DefaultListableBeanFactory@19a20bb2, dubbo version: 3.2.0-beta.4, current host: 192.168.5.6
与目标 VM 断开连接, 地址为: ''127.0.0.1:63465',传输: '套接字''

进程已结束,退出代码0

回答

4

我无法使用bootstrap.yml加载配置

但是可以暂时使用spring.config.import的方式解决使用nacos作为配置中心的问题

以下为application.yml示例配置

spring:
  application:
    name: ****
  config:
    import:
      - "nacos:******.yml?group=user-center"
      - "nacos:zookeeper.yml?group=middleware"
      - "nacos:postgresql.yml?group=middleware"

  cloud:
    nacos:
      config:
        server-addr: ****:8848
        namespace: ***
        username: ***
        password: ***
1

image 这个看起来是有地方触发了 JVM 的 shutdown hook 了,是不是 Spring 启动已经没成功了导致的

3

2023-02-06T16:49:04.905+08:00 INFO 15550 --- [ main] c.c.micro.user.app.UserAppApplication : Started UserAppApplication in 6.088 seconds (process running for 6.675)

spring已经启动成功了

2023-02-06T16:49:04.905+08:00 INFO 15550 --- [ main] c.c.micro.user.app.UserAppApplication : Started UserAppApplication in 6.088 seconds (process running for 6.675)

1

启动日志里 也没有error日志

4

org.apache.dubbo.config.DubboShutdownHook#run 这里打下断点,看一下是为什么进去

7
image

我无法找到为什么 shutdown

2

但是该原因可能不是dubbo导致的,也有可能是bootstrap与spring版本不兼容,我使用了spring boot3 ,可能相关适配有些问题

1

请问一下这个问题您解决了么,我们项目升级3.0时候也是遇到这个问题,我们需要使用spring-cloud-starter-alibaba-nacos-config做为配置刷新。但是spring-cloud-starter-alibaba-nacos-config和Dubbo3好像冲突,引入后就会这样,单纯引入nacos-client就不会

9

请问一下这个问题您解决了么,我们项目升级3.0时候也是遇到这个问题,我们需要使用spring-cloud-starter-alibaba-nacos-config做为配置刷新。但是spring-cloud-starter-alibaba-nacos-config和Dubbo3好像冲突,引入后就会这样,单纯引入nacos-client就不会

我通过这种方式,临时解决了,但是配置自动更新失效了 https://github.com/apache/dubbo/issues/11488#issuecomment-1418900212

2

这个官方没有解决方案了吗

3

这个官方没有解决方案了吗 官方解决方案不清楚,我这样解决对付用了 private static final CountDownLatch countDownLatch = new CountDownLatch(1);

public static void main(String[] args) throws InterruptedException, IOException {
    SpringApplication.run(CoreServiceApplication.class, args);
    countDownLatch.await();
}