http://code.alibabatech.com/schema/dubbo
以上是服务提供者配置文件:
-dubbo协议对外暴漏的端口20880-
-注册中心zk的2181端口
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZookeeperRegistry: [DUBBO] Load registry store file C:\Users\Administrator\.dubbo\dubbo-registry-localhost.cache, data: {com.alibaba.dubbo.demo.DemoService=empty://172.16.4.177/com.alibaba.dubbo.demo.DemoService?application=demotest-consumer&category=providers&dubbo=2.5.3&interface=com.alibaba.dubbo.demo.DemoService&methods=getUserByName&organization=dubbox&owner=programmer&pid=11460&side=consumer×tamp=1518168260112 empty://172.16.4.177/com.alibaba.dubbo.demo.DemoService?application=demotest-consumer&category=configurators&dubbo=2.5.3&interface=com.alibaba.dubbo.demo.DemoService&methods=getUserByName&organization=dubbox&owner=programmer&pid=11460&side=consumer×tamp=1518168260112 empty://172.16.4.177/com.alibaba.dubbo.demo.DemoService?application=demotest-consumer&category=routers&dubbo=2.5.3&interface=com.alibaba.dubbo.demo.DemoService&methods=getUserByName&organization=dubbox&owner=programmer&pid=11460&side=consumer×tamp=1518168260112, com.alibaba.dubbo.service.RoleService=empty://172.16.4.177:20880/com.alibaba.dubbo.service.RoleService?anyhost=true&application=demotest-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.alibaba.dubbo.service.RoleService&methods=modify,getAll,get,create,getALlRoles,remove&organization=dubbox&owner=programmer&pid=17736&revision=api&side=provider×tamp=1520319369195, com.alibaba.dubbo.service.UserService=empty://172.16.4.177:20880/com.alibaba.dubbo.service.UserService?anyhost=true&application=demotest-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.alibaba.dubbo.service.UserService&methods=modify,getAll,get,getALlUsers,create,remove&organization=dubbox&owner=programmer&pid=17736&revision=api&side=provider×tamp=1520319371093}, dubbo version: 2.5.3, current host: 127.0.0.1
C:\Users\Administrator\.dubbo\dubbo-registry-localhost.cache
这个文件是从注册中心缓存下来的服务数据(如图):
打开看下,就是三组我们服务提供者在注册中心中注册过的三个服务:
这里多出的一个DemoService其实早在之前我已经从服务提供者中删除掉了,但是消费者本地缓存中还保留了一个,这是需要注意的一个地方。如图,zk注册中心也没有DemoService:
我们拿出缓存文件中的UserService看下结构:
com.alibaba.dubbo.service.UserService=
empty\://172.16.4.177/com.alibaba.dubbo.service.UserService?
application\=demotest-consumer
&category\=configurators
&check\=false
&dubbo\=2.5.3
&interface\=com.alibaba.dubbo.service.UserService
&methods\=modify,getAll,get,getALlUsers,create,remove
&organization\=dubbox
&owner\=programmer
&pid\=20380
&revision\=api
&side\=consumer
×tamp\=1520319406182
---服务消费者信息
empty\://172.16.4.177/com.alibaba.dubbo.service.UserService
?application\=demotest-consumer
&category\=routers
&check\=false
&dubbo\=2.5.3
&interface\=com.alibaba.dubbo.service.UserService
&methods\=modify,getAll,get,getALlUsers,create,remove
&organization\=dubbox
&owner\=programmer
&pid\=20380
&revision\=api
&side\=consumer
×tamp\=1520319406182
---服务提供者信息
dubbo\://172.16.4.177\:20880/com.alibaba.dubbo.service.UserService
?anyhost\=true
&application\=demotest-provider
&dubbo\=2.5.3
&interface\=com.alibaba.dubbo.service.UserService
&methods\=modify,getAll,get,getALlUsers,create,remove
&organization\=dubbox
&owner\=programmer
&pid\=17736
&revision\=api
&side\=provider
×tamp\=1520319371093
ps:以上三段其实是在缓存文件中的同一行使用空格隔开。
[06/03/18 02:56:46:046 CST] ZkClient-EventThread-24-localhost:2181 INFO zkclient.ZkEventThread: Starting ZkClient event thread.
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:host.name=UCPAA-20170809U
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:java.version=1.8.0_151
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:java.home=D:\Java8\jdk1.8.0_151\jre
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:java.class.path=D:\apache-tomcat-8.0.49\bin\bootstrap.jar;D:\apache-tomcat-8.0.49\bin\tomcat-juli.jar;D:\Java8\jdk1.8.0_151\lib\tools.jar
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:java.library.path=D:\Java8\jdk1.8.0_151\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\Java8\jdk1.8.0_151\jre\bin;C:\Program Files\dotnet\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\Java\jdk1.7.0_04\bin;D:\Java\jdk1.7.0_04\jre\bin;D:\apache-maven-3.5.0\bin;D:\Python27;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files\nodejs\;D:\apache-cxf-3.1.13\bin;C:\Program Files\TortoiseSVN\bin;C:\Users\Administrator\AppData\Local\Programs\Fiddler;.
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=C:\Users\Administrator\AppData\Local\Temp\
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:java.compiler=
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:os.name=Windows 7
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:os.arch=amd64
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:os.version=6.1
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:user.name=Administrator
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:user.home=C:\Users\Administrator
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Client environment:user.dir=C:\Users\Administrator\Downloads\eclipse-jee-mars-2-win32-x86_64\eclipse
以上打印的是消费者的zk客户端开始zk服务器了....
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.I0Itec.zkclient.ZkClient@278d600f
初始化zk客户端连接,端口2181,会话30s超时....
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zkclient.ZkClient: Waiting for keeper state SyncConnected
[06/03/18 02:56:46:046 CST] localhost-startStop-1-SendThread(127.0.0.1:2181) INFO zookeeper.ClientCnxn: Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
[06/03/18 02:56:46:046 CST] localhost-startStop-1-SendThread(127.0.0.1:2181) INFO zookeeper.ClientCnxn: Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
[06/03/18 02:56:46:046 CST] localhost-startStop-1-SendThread(127.0.0.1:2181) WARN zookeeper.ClientCnxnSocket: Connected to an old server; r-o mode will be unavailable
[06/03/18 02:56:46:046 CST] localhost-startStop-1-SendThread(127.0.0.1:2181) INFO zookeeper.ClientCnxn: Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x161fa17aa410001, negotiated timeout = 30000
[06/03/18 02:56:46:046 CST] localhost-startStop-1-EventThread INFO zkclient.ZkClient: zookeeper state changed (SyncConnected)
打开socket长连接并连同zk注册中心....
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZookeeperRegistry: [DUBBO] Register: consumer://172.16.4.177/com.alibaba.dubbo.service.UserService?application=demotest-consumer&category=consumers&check=false&dubbo=2.5.3&interface=com.alibaba.dubbo.service.UserService&methods=modify,getAll,get,getALlUsers,create,remove&organization=dubbox&owner=programmer&pid=20380&revision=api&side=consumer×tamp=1520319406182, dubbo version: 2.5.3, current host: 172.16.4.177
[06/03/18 02:56:46:046 CST] localhost-startStop-1 INFO zookeeper.ZookeeperRegistry: [DUBBO] Subscribe: consumer://172.16.4.177/com.alibaba.dubbo.service.UserService?application=demotest-consumer&category=providers,configurators,routers&check=false&dubbo=2.5.3&interface=com.alibaba.dubbo.service.UserService&methods=modify,getAll,get,getALlUsers,create,remove&organization=dubbox&owner=programmer&pid=20380&revision=api&side=consumer×tamp=1520319406182, dubbo version: 2.5.3, current host: 172.16.4.177
[06/03/18 02:56:47:047 CST] localhost-startStop-1 INFO zookeeper.ZookeeperRegistry: [DUBBO] Notify urls for subscribe url consumer://172.16.4.177/com.alibaba.dubbo.service.UserService?application=demotest-consumer&category=providers,configurators,routers&check=false&dubbo=2.5.3&interface=com.alibaba.dubbo.service.UserService&methods=modify,getAll,get,getALlUsers,create,remove&organization=dubbox&owner=programmer&pid=20380&revision=api&side=consumer×tamp=1520319406182, urls: [dubbo://172.16.4.177:20880/com.alibaba.dubbo.service.UserService?anyhost=true&application=demotest-provider&dubbo=2.5.3&interface=com.alibaba.dubbo.service.UserService&methods=modify,getAll,get,getALlUsers,create,remove&organization=dubbox&owner=programmer&pid=17736&revision=api&side=provider×tamp=1520319371093, empty://172.16.4.177/com.alibaba.dubbo.service.UserService?application=demotest-consumer&category=configurators&check=false&dubbo=2.5.3&interface=com.alibaba.dubbo.service.UserService&methods=modify,getAll,get,getALlUsers,create,remove&organization=dubbox&owner=programmer&pid=20380&revision=api&side=consumer×tamp=1520319406182, empty://172.16.4.177/com.alibaba.dubbo.service.UserService?application=demotest-consumer&category=routers&check=false&dubbo=2.5.3&interface=com.alibaba.dubbo.service.UserService&methods=modify,getAll,get,getALlUsers,create,remove&organization=dubbox&owner=programmer&pid=20380&revision=api&side=consumer×tamp=1520319406182], dubbo version: 2.5.3, current host: 172.16.4.177
消费者向注册中心订阅自己需要的服务.....
[06/03/18 02:56:47:047 CST] localhost-startStop-1 INFO transport.AbstractClient: [DUBBO] Successed connect to server /172.16.4.177:20880 from NettyClient 172.16.4.177 using dubbo version 2.5.3, channel is NettyChannel [channel=[id: 0x9d9c7040, /172.16.4.177:58664 => /172.16.4.177:20880]], dubbo version: 2.5.3, current host: 172.16.4.177
[06/03/18 02:56:47:047 CST] localhost-startStop-1 INFO transport.AbstractClient: [DUBBO] Start NettyClient UCPAA-20170809U/172.16.4.177 connect to the server /172.16.4.177:20880, dubbo version: 2.5.3, current host: 172.16.4.177
[06/03/18 02:56:47:047 CST] localhost-startStop-1 INFO config.AbstractConfig: [DUBBO] Refer dubbo service com.alibaba.dubbo.service.UserService from url zookeeper://localhost:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=demotest-consumer&check=false&dubbo=2.5.3&interface=com.alibaba.dubbo.service.UserService&methods=modify,getAll,get,getALlUsers,create,remove&organization=dubbox&owner=programmer&pid=20380&revision=api&side=consumer×tamp=1520319406182, dubbo version: 2.5.3, current host: 172.16.4.177
[06/03/18 02:56:47:047 CST] localhost-startStop-1 INFO handler.SimpleUrlHandlerMapping: Mapped URL path [/static/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
[06/03/18 02:56:48:048 CST] localhost-startStop-1 INFO servlet.DispatcherServlet: FrameworkServlet 'mvc-dispatcher': initialization completed in 4920 ms
当我们向浏览器请求消费者接口,消费者会从本地缓存列表中拿出getAllUsers接口以及对应的服务端地址端口进行rpc调用获取数据。