Dubbo 应用 XML配置分析
- 演示案例:
- 提供者代码
- xml配置
- 消费者代码
- xml配置
参考地址:
-
手动配置
- https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/config/overview/
-
配置说明
- xml配置
- https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/config/xml/
- 配置工作原理
- https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/config/principle/
- xml配置
-
配置项手册
- https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/config/properties/#protocol
protocol
provider
consumer
config-center
演示案例:
提供者代码
public class Application {public static void main(String[] args) throws Exception {ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-provider.xml");context.start();System.in.read();}
}
xml配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"xmlns="http://www.springframework.org/schema/beans"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsdhttp://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"><!--dubbo:application:指定应用名等应用级别相关信息【必填】--><dubbo:application name="demo-provider" metadata-type="remote"><dubbo:parameter key="mapping-type" value="metadata"/></dubbo:application><!--dubbo:config-center: 配置中心类型、地址及相关配置metadata-report:元数据中心类型、地址及相关配置registry:注册中心类型、地址及相关配置【必填】--><dubbo:config-center address="zookeeper://10.151.110.52:2181"/><dubbo:metadata-report address="zookeeper://10.151.110.52:2181"/><dubbo:registry id="registry1" address="zookeeper://10.151.110.52:2181"/><!--dubbo:protocol:要暴露的 RPC 协议及相关配置如端口号等--><dubbo:protocol name="dubbo" port="-1"/><bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/><bean id="greetingService" class="org.apache.dubbo.demo.provider.GreetingServiceImpl"/><!--dubbo:service:声明普通接口或实现类为 Dubbo 服务--><dubbo:service interface="org.apache.dubbo.demo.DemoService" timeout="3000" ref="demoService" registry="registry1"/><dubbo:service version="1.0.0" group="greeting" timeout="5000" interface="org.apache.dubbo.demo.GreetingService"ref="greetingService"/></beans>
privoder控制台打印
[20/11/23 14:55:45:341 CST] DubboSaveMetadataReport-thread-1 INFO zookeeper.ZookeeperMetadataReport: [DUBBO] store provider metadata. Identifier : org.apache.dubbo.metadata.report.identifier.MetadataIdentifier@c8ae94a; definition: FullServiceDefinition{parameters={mapping-type=metadata, side=provider, service.name=ServiceBean:greeting/org.apache.dubbo.demo.GreetingService:1.0.0, release=, methods=hello, deprecated=false, qos.port=22222, dubbo=2.0.2, interface=org.apache.dubbo.demo.GreetingService, version=1.0.0, generic=false, timeout=5000, revision=1.0.0, mapping.type=metadata, metadata-type=remote, application=demo-provider, dynamic=true, group=greeting, anyhost=true}} ServiceDefinition [canonicalName=org.apache.dubbo.demo.GreetingService, codeSource=file:/D:/apache_projects/dubbo/dubbo-demo/dubbo-demo-interface/target/classes/, methods=[MethodDefinition [name=hello, parameterTypes=[], returnType=java.lang.String]]], dubbo version: , current host: 192.168.109.130[20/11/23 14:55:45:351 CST] main INFO config.ServiceConfig: [DUBBO] No valid ip found from environment, try to get local host., dubbo version: , current host: 192.168.109.130[20/11/23 14:55:45:353 CST] main INFO config.ServiceConfig: [DUBBO] Export dubbo service org.apache.dubbo.demo.DemoService to local registry url : injvm://127.0.0.1/org.apache.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bind.ip=192.168.109.130&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=13704&qos.port=22222&release=&service.name=ServiceBean:/org.apache.dubbo.demo.DemoService&side=provider&timeout=3000×tamp=1700463345344, dubbo version: , current host: 192.168.109.130[20/11/23 14:55:45:354 CST] main INFO config.ServiceConfig: [DUBBO] Register dubbo service org.apache.dubbo.demo.DemoService url dubbo://192.168.109.130:20880/org.apache.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bind.ip=192.168.109.130&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=13704&qos.port=22222&release=&service.name=ServiceBean:/org.apache.dubbo.demo.DemoService&side=provider&timeout=3000×tamp=1700463345344 to registry registry://192.168.109.130:2181/org.apache.dubbo.registry.RegistryService?application=demo-provider&dubbo=2.0.2&id=registry1&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&pid=13704&qos.port=22222®istry=zookeeper×tamp=1700463345343, dubbo version: , current host: 192.168.109.130[20/11/23 14:55:45:357 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Register: dubbo://192.168.109.130:20880/org.apache.dubbo.demo.DemoService?anyhost=true&application=demo-provider&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=13704&release=&service.name=ServiceBean:/org.apache.dubbo.demo.DemoService&side=provider&timeout=3000×tamp=1700463345344, dubbo version: , current host: 192.168.109.130[20/11/23 14:55:45:359 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Subscribe: provider://192.168.109.130:20880/org.apache.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bind.ip=192.168.109.130&bind.port=20880&category=configurators&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=13704&qos.port=22222&release=&service.name=ServiceBean:/org.apache.dubbo.demo.DemoService&side=provider&timeout=3000×tamp=1700463345344, dubbo version: , current host: 192.168.109.130[20/11/23 14:55:45:361 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Notify urls for subscribe url provider://192.168.109.130:20880/org.apache.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bind.ip=192.168.109.130&bind.port=20880&category=configurators&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=13704&qos.port=22222&release=&service.name=ServiceBean:/org.apache.dubbo.demo.DemoService&side=provider&timeout=3000×tamp=1700463345344, urls: [empty://192.168.109.130:20880/org.apache.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bind.ip=192.168.109.130&bind.port=20880&category=configurators&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=13704&qos.port=22222&release=&service.name=ServiceBean:/org.apache.dubbo.demo.DemoService&side=provider&timeout=3000×tamp=1700463345344], dubbo version: , current host: 192.168.109.130[20/11/23 14:55:45:364 CST] DubboSaveMetadataReport-thread-1 INFO zookeeper.ZookeeperMetadataReport: [DUBBO] store provider metadata. Identifier : org.apache.dubbo.metadata.report.identifier.MetadataIdentifier@441ae1a3; definition: FullServiceDefinition{parameters={mapping-type=metadata, side=provider, service.name=ServiceBean:/org.apache.dubbo.demo.DemoService, release=, methods=sayHello,sayHelloAsync, deprecated=false, qos.port=22222, dubbo=2.0.2, interface=org.apache.dubbo.demo.DemoService, generic=false, timeout=3000, mapping.type=metadata, metadata-type=remote, application=demo-provider, dynamic=true, anyhost=true}} ServiceDefinition [canonicalName=org.apache.dubbo.demo.DemoService, codeSource=file:/D:/apache_projects/dubbo/dubbo-demo/dubbo-demo-interface/target/classes/, methods=[MethodDefinition [name=sayHello, parameterTypes=[java.lang.String], returnType=java.lang.String], MethodDefinition [name=sayHelloAsync, parameterTypes=[java.lang.String], returnType=java.util.concurrent.CompletableFuture]]], dubbo version: , current host: 192.168.109.130[20/11/23 14:55:45:369 CST] main INFO bootstrap.DubboBootstrap: [DUBBO] DubboBootstrap is ready., dubbo version: , current host: 192.168.109.130[20/11/23 14:55:45:371 CST] main INFO bootstrap.DubboBootstrap: [DUBBO] DubboBootstrap has started., dubbo version: , current host: 192.168.109.130
消费者代码
public class Application {/*** In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before* launch the application*/public static void main(String[] args) throws Exception {ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");context.start();DemoService demoService = context.getBean("demoService", DemoService.class);GreetingService greetingService = context.getBean("greetingService", GreetingService.class);new Thread(() -> {while (true) {String greetings = greetingService.hello();System.out.println(greetings + " from separated thread.");try {Thread.sleep(5000);} catch (InterruptedException e) {e.printStackTrace();}}}).start();while (true) {CompletableFuture<String> hello = demoService.sayHelloAsync("world");System.out.println("result: " + hello.get());String greetings = greetingService.hello();System.out.println("result: " + greetings);Thread.sleep(5000);}}
}
consumer控制台打印
[20/11/23 15:02:29:857 CST] main INFO zookeeper.ZooKeeper: Initiating client connection, connectString=192.168.109.130:2181 sessionTimeout=60000 watcher=org.apache.curator.ConnectionState@4d098f9b[20/11/23 15:02:29:922 CST] main-SendThread(r.nacos.com:2181) INFO zookeeper.ClientCnxn: Opening socket connection to server r.nacos.com/192.168.109.130:2181. Will not attempt to authenticate using SASL (unknown error)[20/11/23 15:02:29:922 CST] main-SendThread(r.nacos.com:2181) INFO zookeeper.ClientCnxn: Socket connection established to r.nacos.com/192.168.109.130:2181, initiating session[20/11/23 15:02:29:923 CST] main INFO imps.CuratorFrameworkImpl: Default schema[20/11/23 15:02:29:932 CST] main-SendThread(r.nacos.com:2181) INFO zookeeper.ClientCnxn: Session establishment complete on server r.nacos.com/192.168.109.130:2181, sessionid = 0x10001273e960005, negotiated timeout = 40000[20/11/23 15:02:29:939 CST] main-EventThread INFO state.ConnectionStateManager: State change: CONNECTED # 连接状态[20/11/23 15:02:29:940 CST] main INFO zookeeper.ZookeeperTransporter: [DUBBO] No valid zookeeper client found from cache, therefore create a new client for url. zookeeper://192.168.109.130:2181/ConfigCenterConfig?check=true&config-file=dubbo.properties&group=dubbo&highest-priority=false&timeout=3000, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:29:962 CST] Curator-ConnectionStateManager-0 INFO curator.CuratorZookeeperClient: [DUBBO] Curator zookeeper client instance initiated successfully, session id is 10001273e960005, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:29:986 CST] main INFO bootstrap.DubboBootstrap: [DUBBO] No global configuration in config center, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:29:987 CST] main INFO bootstrap.DubboBootstrap: [DUBBO] No application level configuration in config center, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:008 CST] main INFO utils.ConfigValidationUtils: [DUBBO] No valid monitor config found, specify monitor info to enable collection of Dubbo statistics, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:039 CST] main INFO zookeeper.ZookeeperMetadataReport: [DUBBO] Load service store file C:\Users\.dubbo\dubbo-metadata-demo-consumer-192.168.109.130-2181.cache, data: {org.apache.dubbo.demo.DemoService:::consumer:demo-consumer={"mapping-type":"metadata","init":"false","side":"consumer","release":"","methods":"sayHello,sayHelloAsync","qos.port":"33333","dubbo":"2.0.2","check":"true","interface":"org.apache.dubbo.demo.DemoService","enable.auto.migration":"true","mapping.type":"metadata","metadata-type":"remote","application":"demo-consumer","sticky":"false","enable-auto-migration":"true"}, org.apache.dubbo.demo.GreetingService:1.0.0:greeting:consumer:demo-consumer={"mapping-type":"metadata","init":"false","side":"consumer","release":"","methods":"hello","qos.port":"33333","dubbo":"2.0.2","check":"false","interface":"org.apache.dubbo.demo.GreetingService","version":"1.0.0","revision":"1.0.0","enable.auto.migration":"true","mapping.type":"metadata","metadata-type":"remote","application":"demo-consumer","sticky":"false","enable-auto-migration":"true","group":"greeting"}}, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:060 CST] main INFO zookeeper.ZookeeperTransporter: [DUBBO] find valid zookeeper client from the cache for address: zookeeper://192.168.109.130:2181/org.apache.dubbo.metadata.report.MetadataReport?application=demo-consumer&port=2181&protocol=zookeeper, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:066 CST] main INFO bootstrap.DubboBootstrap: [DUBBO] DubboBootstrap has been initialized!, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:066 CST] main INFO bootstrap.DubboBootstrap: [DUBBO] DubboBootstrap is starting..., dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:071 CST] main INFO bootstrap.DubboBootstrap: [DUBBO] DubboBootstrap is ready., dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:074 CST] main INFO bootstrap.DubboBootstrap: [DUBBO] DubboBootstrap has started., dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:144 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Load registry cache file C:\Users\.dubbo\dubbo-registry-demo-consumer-192.168.109.130-2181.cache, data: {greeting/org.apache.dubbo.demo.GreetingService:1.0.0=empty://192.168.109.130/org.apache.dubbo.demo.GreetingService?application=demo-consumer&category=routers&check=false&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&group=greeting&init=false&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=4068&qos.port=33333&revision=1.0.0&side=consumer&sticky=false×tamp=1700462778060&version=1.0.0 empty://192.168.109.130/org.apache.dubbo.demo.GreetingService?application=demo-consumer&category=configurators&check=false&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&group=greeting&init=false&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=4068&qos.port=33333&revision=1.0.0&side=consumer&sticky=false×tamp=1700462778060&version=1.0.0 empty://192.168.109.130/org.apache.dubbo.demo.GreetingService?application=demo-consumer&category=providers&check=false&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&group=greeting&init=false&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=4068&qos.port=33333&revision=1.0.0&side=consumer&sticky=false×tamp=1700462778060&version=1.0.0, org.apache.dubbo.demo.DemoService=empty://192.168.109.130/org.apache.dubbo.demo.DemoService?application=demo-consumer&category=routers&check=true&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&init=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=4068&qos.port=33333&side=consumer&sticky=false×tamp=1700462777472 empty://192.168.109.130/org.apache.dubbo.demo.DemoService?application=demo-consumer&category=configurators&check=true&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&init=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=4068&qos.port=33333&side=consumer&sticky=false×tamp=1700462777472 empty://192.168.109.130/org.apache.dubbo.demo.DemoService?application=demo-consumer&category=providers&check=true&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&init=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=4068&qos.port=33333&side=consumer&sticky=false×tamp=1700462777472}, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:144 CST] main INFO zookeeper.ZookeeperTransporter: [DUBBO] find valid zookeeper client from the cache for address: zookeeper://192.168.109.130:2181/org.apache.dubbo.registry.RegistryService?application=demo-consumer&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&id=org.apache.dubbo.config.RegistryConfig&interface=org.apache.dubbo.registry.RegistryService&mapping-type=metadata&mapping.type=metadata&pid=17228&qos.port=33333×tamp=1700463750102, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:155 CST] main INFO migration.MigrationRuleListener: [DUBBO] Listening for migration rules on dataId-demo-consumer.migration group-MIGRATION, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:156 CST] main INFO migration.MigrationRuleListener: [DUBBO] Using the following migration rule to migrate:, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:157 CST] main INFO migration.MigrationRuleListener: [DUBBO] INIT, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:176 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Register: consumer://192.168.109.130/org.apache.dubbo.demo.DemoService?application=demo-consumer&category=consumers&check=false&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&init=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=17228&qos.port=33333&side=consumer&sticky=false×tamp=1700463750085, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:192 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Subscribe: consumer://192.168.109.130/org.apache.dubbo.demo.DemoService?application=demo-consumer&category=providers,configurators,routers&check=true&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&init=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=17228&qos.port=33333&side=consumer&sticky=false×tamp=1700463750085, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:204 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Notify urls for subscribe url consumer://192.168.109.130/org.apache.dubbo.demo.DemoService?application=demo-consumer&category=providers,configurators,routers&check=true&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&init=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=17228&qos.port=33333&side=consumer&sticky=false×tamp=1700463750085, urls: [dubbo://192.168.109.130:20880/org.apache.dubbo.demo.DemoService?anyhost=true&application=demo-provider&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=13704&release=release&service.name=ServiceBean:/org.apache.dubbo.demo.DemoService&side=provider&timeout=3000×tamp=1700463345344, empty://192.168.109.130/org.apache.dubbo.demo.DemoService?application=demo-consumer&category=configurators&check=true&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&init=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=17228&qos.port=33333&side=consumer&sticky=false×tamp=1700463750085, empty://192.168.109.130/org.apache.dubbo.demo.DemoService?application=demo-consumer&category=routers&check=true&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&init=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=17228&qos.port=33333&side=consumer&sticky=false×tamp=1700463750085], dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:556 CST] NettyClientWorker-1-1 INFO netty4.NettyClientHandler: [DUBBO] The connection of /192.168.109.130:62180 -> /192.168.109.130:20880 is established., dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:560 CST] main INFO transport.AbstractClient: [DUBBO] Successed connect to server /192.168.109.130:20880 from NettyClient 192.168.109.130 using dubbo version , channel is NettyChannel [channel=[id: 0x4d51818c, L:/192.168.109.130:62180 - R:/192.168.109.130:20880]], dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:560 CST] main INFO transport.AbstractClient: [DUBBO] Start NettyClient /192.168.109.130 connect to the server /192.168.109.130:20880, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:593 CST] main INFO config.ReferenceConfig: [DUBBO] Refer dubbo service org.apache.dubbo.demo.DemoService from url dubbo://192.168.109.130/org.apache.dubbo.demo.DemoService?anyhost=true&application=demo-consumer&check=true&deprecated=false&dubbo=2.0.2&dynamic=true&enable-auto-migration=true&enable.auto.migration=true&generic=false&init=false&interface=org.apache.dubbo.demo.DemoService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=sayHello,sayHelloAsync&pid=17228&qos.port=33333®ister.ip=192.168.109.130&release=release&remote.application=demo-provider&service.name=ServiceBean:/org.apache.dubbo.demo.DemoService&side=consumer&sticky=false&timeout=3000×tamp=1700463750085, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:665 CST] DubboSaveMetadataReport-thread-1 INFO zookeeper.ZookeeperMetadataReport: [DUBBO] store consumer metadata. Identifier : org.apache.dubbo.metadata.report.identifier.MetadataIdentifier@528c11f0; definition: {mapping-type=metadata, init=false, side=consumer, release=, methods=sayHello,sayHelloAsync, qos.port=33333, dubbo=2.0.2, check=true, interface=org.apache.dubbo.demo.DemoService, enable.auto.migration=true, mapping.type=metadata, metadata-type=remote, application=demo-consumer, sticky=false, enable-auto-migration=true}, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:679 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Register: consumer://192.168.109.130/org.apache.dubbo.demo.GreetingService?application=demo-consumer&category=consumers&check=false&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&group=greeting&init=false&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=17228&qos.port=33333&revision=1.0.0&side=consumer&sticky=false×tamp=1700463750672&version=1.0.0, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:683 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Subscribe: consumer://192.168.109.130/org.apache.dubbo.demo.GreetingService?application=demo-consumer&category=providers,configurators,routers&check=false&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&group=greeting&init=false&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=17228&qos.port=33333&revision=1.0.0&side=consumer&sticky=false×tamp=1700463750672&version=1.0.0, dubbo version: , current host: 192.168.109.130
[20/11/23 15:02:30:686 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Notify urls for subscribe url consumer://192.168.109.130/org.apache.dubbo.demo.GreetingService?application=demo-consumer&category=providers,configurators,routers&check=false&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&group=greeting&init=false&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=17228&qos.port=33333&revision=1.0.0&side=consumer&sticky=false×tamp=1700463750672&version=1.0.0, urls: [dubbo://192.168.109.130:20880/org.apache.dubbo.demo.GreetingService?anyhost=true&application=demo-provider&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=greeting&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=13704&release=release&revision=1.0.0&service.name=ServiceBean:greeting/org.apache.dubbo.demo.GreetingService:1.0.0&side=provider&timeout=5000×tamp=1700463344841&version=1.0.0, empty://192.168.109.130/org.apache.dubbo.demo.GreetingService?application=demo-consumer&category=configurators&check=false&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&group=greeting&init=false&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=17228&qos.port=33333&revision=1.0.0&side=consumer&sticky=false×tamp=1700463750672&version=1.0.0, empty://192.168.109.130/org.apache.dubbo.demo.GreetingService?application=demo-consumer&category=routers&check=false&dubbo=2.0.2&enable-auto-migration=true&enable.auto.migration=true&group=greeting&init=false&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=17228&qos.port=33333&revision=1.0.0&side=consumer&sticky=false×tamp=1700463750672&version=1.0.0], dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:688 CST] main INFO config.ReferenceConfig: [DUBBO] Refer dubbo service org.apache.dubbo.demo.GreetingService from url dubbo://192.168.109.130/org.apache.dubbo.demo.GreetingService?anyhost=true&application=demo-consumer&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&enable-auto-migration=true&enable.auto.migration=true&generic=false&group=greeting&init=false&interface=org.apache.dubbo.demo.GreetingService&mapping-type=metadata&mapping.type=metadata&metadata-type=remote&methods=hello&pid=17228&qos.port=33333®ister.ip=192.168.109.130&release=release&remote.application=demo-provider&revision=1.0.0&service.name=ServiceBean:greeting/org.apache.dubbo.demo.GreetingService:1.0.0&side=consumer&sticky=false&timeout=5000×tamp=1700463750672&version=1.0.0, dubbo version: , current host: 192.168.109.130[20/11/23 15:02:30:688 CST] DubboSaveMetadataReport-thread-1 INFO zookeeper.ZookeeperMetadataReport: [DUBBO] store consumer metadata. Identifier : org.apache.dubbo.metadata.report.identifier.MetadataIdentifier@53c78c1b; definition: {mapping-type=metadata, init=false, side=consumer, release=, methods=hello, qos.port=33333, dubbo=2.0.2, check=false, interface=org.apache.dubbo.demo.GreetingService, version=1.0.0, revision=1.0.0, enable.auto.migration=true, mapping.type=metadata, metadata-type=remote, application=demo-consumer, sticky=false, enable-auto-migration=true, group=greeting}, dubbo version: , current host: 192.168.109.130
result: async result
Greetings! from separated thread.
result: Greetings!
Greetings! from separated thread.
result: async result
result: Greetings!
result: async result
Greetings! from separated thread.
xml配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"xmlns="http://www.springframework.org/schema/beans"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsdhttp://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"><dubbo:application name="demo-consumer" ><dubbo:parameter key="mapping-type" value="metadata"/><dubbo:parameter key="enable-auto-migration" value="true"/></dubbo:application><dubbo:metadata-report address="zookeeper://10.151.110.52:2181"/><dubbo:registry address="zookeeper://10.151.110.52:2181"/><!--dubboreference:声明普通接口为 Dubbo 服务
--><dubbo:reference id="demoService" check="true"interface="org.apache.dubbo.demo.DemoService"/><dubbo:reference version="1.0.0" group="greeting" id="greetingService" check="false"interface="org.apache.dubbo.demo.GreetingService"/></beans>