alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.8k stars 8.31k forks source link

Nacos integration with SpringBootAdmin. #3258

Closed anbuis closed 1 year ago

anbuis commented 1 year ago

Which Component eg. SpringCloudAlibaba2021.0.5.0(Nacos Discovery 2021.0.5.0), SpringBootAdmin2.6.11, openjdk8, springcloud2021.0.5

Describe what problem you have encountered 在我使用 SpringCloudAlibaba2021.0.5.0时,SpringBootAdmin无法监控新注册的服务实例。 当我把SpringCloudAlibaba的版本更换为 2021.0.4.0时,SpringBootAdmin可以正常的运行,且能够监控新注册的服务实例。 Translation Software: When I am using SpringCloudAlibaba 2021.0.5.0, SpringBootAdmin is not able to monitor newly registered service instances. When I changed the version of SpringCloudAlibaba to 2021.0.4.0, SpringBootAdmin works fine and is able to monitor newly registered service instances.

Describe what information you have read 我阅读了SpringBootAdmin的文档,并且根据文档进行了配置。 I read the documentation of SpringBootAdmin and configured it according to the documentation. 我也根据nacos-discovery的说明文档开启了NacosWatch。 I also turned on NacosWatch according to the nacos-discovery instruction document.

yuluo-yx commented 1 year ago

Can you provide a simple example? Facilitate community students to reproduce and repair problems.

karl-chanel commented 1 year ago

@yuluo-yx It's a long existing problem, Issues have been raised among spring boot admin repo and this repo and nacos repo, I don't really know what the problem is, But the advice they give from the spring boot admin repo didnt solve the problem, It's really weird,hope u give this a deep Investigating.https://github.com/codecentric/spring-boot-admin/issues/2201#issue-1526742532

yuluo-yx commented 1 year ago

@yuluo-yx It's a long existing problem, Issues have been raised among spring boot admin repo and this repo and nacos repo, I don't really know what the problem is, But the advice they give from the spring boot admin repo didnt solve the problem, It's really weird,hope u give this a deep Investigating.codecentric/spring-boot-admin#2201 (comment)

ok, the community will discuss this issue at the weekly meeting, welcome to attend!

karl-chanel commented 1 year ago

@ruansheng8 @steverao i did a test,sba only works fine with spring cloud alibaba 2021.04 , the 2021.05 and 2022 above have the same problem, and from 2021.04 to 2021.05 you guys refactored the nacoswatch (i think thats the cause),when i set nacoswatch enable to true ,it doesnt fix the problem, and when i use spring cloud alibaba 2021.05 ,if use the discovery dependency from 2021.0.4,it also works fine,just like below, so i think this pr https://github.com/alibaba/spring-cloud-alibaba/pull/2881#issue-1430822543 does some changes and make things crack

屏幕截图 2023-05-04 193734
karl-chanel commented 1 year ago

and i tried consul ,sba is working fine

karl-chanel commented 1 year ago

i found the pr https://github.com/alibaba/spring-cloud-alibaba/pull/2881 ,it's likely this pr caused all the problem ,i'll get some time to understand what it does ,and why it brings the problem@ruansheng8 @steverao

karl-chanel commented 1 year ago

i find a very stupid way to fix this problem ,no matter you are using sca 2021.05 or 2022 and above, it all works ,add the redundant spring cloud gateway dependency(even if you dont need) and set spring.cloud.gateway.discovery.locator.enabled=true and also enable nacoswatch, then problem solved ,this is because sba use HeartbeatEvent to discovery new services ,but pr https://github.com/alibaba/spring-cloud-alibaba/pull/2881#issue-1430822543 makes it enabled in just gateway scenario ,it's a long existing bug affecting all the releases after 2021.04 , So there's literally nothing wrong with sba , Even if they got a lot of new issues raised about this problem ,hope you fix it soon@ruansheng8

karl-chanel commented 1 year ago

@steverao pr 2881 改变了nacoswatch的逻辑,同时去除了heatbeatevent的发布,spring boot admin 依赖heartbeatevent去拉取nacos的服务,导致spring cloud alibaba 2021.04后的所有版本无法与spring boot admin集成 ,临时解决办法可以手动写一个heatbeatpublisher 手动完成事件的发布,或者愚蠢的把spring cloud gateway 的依赖加进来,再配spring.cloud.gateway.discovery.locator.enabled=true,除去以上所有,我们如果不考虑与spring boot admin的集成问题,GatewayLocatorHeartBeatPublisher的逻辑也有一些小问题,在start方法里并没有设置running状态为true,导致stop方法永远无法被调用,我在本地已经测试过了只有在running在start中被设未true后,在spring容器销毁时才会进入stop方法的逻辑

zhangbinhub commented 1 year ago

There is another foolish way, without dependency the spring cloud gateway, simply set spring.cloud.gateway.discovery.locator.enabled to true

karl-chanel commented 1 year ago

There is another foolish way, without dependency the spring cloud gateway, simply set spring.cloud.gateway.discovery.locator.enabled to true

as i mentioned before , when you config like this , the default heartbeatpublisher will be activated ,and this bean has a little problem as i mentioned above

github-actions[bot] commented 1 year ago

This issue has been open 30 days with no activity. This will be closed in 7 days.

ruansheng8 commented 1 year ago

The issue has been fixed and will be supported in the next release. #3318