Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with dubbo registry zookeeper #316

Open
songxiaosheng opened this issue May 8, 2023 · 6 comments
Open

Compatibility with dubbo registry zookeeper #316

songxiaosheng opened this issue May 8, 2023 · 6 comments

Comments

@songxiaosheng
Copy link

songxiaosheng commented May 8, 2023

Describe the bug
Please provide details of the problem, including the version of Spring Cloud that you
are using.

java.lang.RuntimeException: java.lang.ClassCastException: Cannot cast org.springframework.cloud.zookeeper.discovery.ZookeeperInstance to org.apache.dubbo.registry.zookeeper.ZookeeperInstance
	at org.apache.dubbo.common.function.ThrowableFunction.execute(ThrowableFunction.java:54) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.common.function.ThrowableFunction.execute(ThrowableFunction.java:69) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.doInServiceDiscovery(ZookeeperServiceDiscovery.java:188) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.getInstances(ZookeeperServiceDiscovery.java:147) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribeURLs(ServiceDiscoveryRegistry.java:319) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:225) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:187) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:88) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:184) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:134) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:581) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:440) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:246) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:76) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:60) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:249) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:546) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:516) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:498) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:85) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:80) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.refer(ProtocolSecurityWrapper.java:107) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.refer(InvokerCountWrapper.java:48) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.ReferenceConfig.createInvoker(ReferenceConfig.java:586) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:432) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:295) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:231) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.utils.SimpleReferenceCache.destroyReference(SimpleReferenceCache.java:265) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.utils.SimpleReferenceCache.destroy(SimpleReferenceCache.java:218) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.utils.SimpleReferenceCache.destroy(SimpleReferenceCache.java:242) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:414) ~[dubbo-3.2.0.jar:3.2.0]
	at java.base/java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4783) ~[na:na]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:389) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:170) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:142) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:113) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:102) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:47) ~[dubbo-3.2.0.jar:3.2.0]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:937) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:587) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293) ~[spring-boot-3.0.6.jar:3.0.6]
	at com.michael.dubbo.ConsumerApplication.main(ConsumerApplication.java:19) ~[classes/:na]
Caused by: java.lang.ClassCastException: Cannot cast org.springframework.cloud.zookeeper.discovery.ZookeeperInstance to org.apache.dubbo.registry.zookeeper.ZookeeperInstance
	at java.base/java.lang.Class.cast(Class.java:3991) ~[na:na]
	at org.apache.curator.x.discovery.details.JsonInstanceSerializer.deserialize(JsonInstanceSerializer.java:87) ~[curator-x-discovery-5.1.0.jar:na]
	at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.queryForInstance(ServiceDiscoveryImpl.java:325) ~[curator-x-discovery-5.1.0.jar:na]
	at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.queryForInstances(ServiceDiscoveryImpl.java:393) ~[curator-x-discovery-5.1.0.jar:na]
	at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.queryForInstances(ServiceDiscoveryImpl.java:307) ~[curator-x-discovery-5.1.0.jar:na]
	at org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.lambda$getInstances$2(ZookeeperServiceDiscovery.java:147) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.common.function.ThrowableFunction.execute(ThrowableFunction.java:52) ~[dubbo-3.2.0.jar:3.2.0]
	... 55 common frames omitted

Sample

When using dubbo to interact with spring, the registry type conversion is abnormal. Is spring cloud compatible with dubbo's application-level instance registry?

Dubbo Issue As follow

apache/dubbo#12243

@songxiaosheng
Copy link
Author

Is there anyone who can support this feature? It requires compatibility between Dubbo and Spring. If compatibility is complete, it can be interconnected

@spencergibb
Copy link
Member

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

I am unfamiliar with how dubbo work and what, if anything, we could do to make them compatible. Can you tell me what would need to change?

@songxiaosheng
Copy link
Author

songxiaosheng commented May 10, 2023

Thank you for your reply,
Dubbo and Spring Cloud Zookeeper are both based on the implementation of curator services. It is found that both use custom types when storing data, which makes them incompatible. If Dubbo and Spring Cloud can be compatible with each other's application level service data, interconnection can be achieved. However, both sides need to be compatible. The instance information of Dubbo and Spring Cloud needs to be changed together,

@songxiaosheng
Copy link
Author

The service discovery code for Dubbo is as follows:
https://github.com/apache/dubbo/tree/3.2/dubbo-registry/dubbo-registry-zookeeper

@spencergibb
Copy link
Member

I understand that from your previous comments. I don't have the dubbo expertise to do the work to even know what to do make them compatible. Pull requests welcome.

@spencergibb spencergibb changed the title dubbo to interact with spring bug Compatibility with dubbo registry zookeeper May 10, 2023
@songxiaosheng
Copy link
Author

Okay, I'll take on this task. The interconnection between Spring Cloud Zookeeper and Dubbo Zookeeper helps enterprises better use scenarios where the two frameworks coexist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants