一、目标:
由于培训需要演示dubbo的快速实战,因此有了本文,再次声明,本文不是最佳配置。
使用dubbo,构建一个provider提供视频信息服务,一个consumer获取视频信息服务并调用。
文中zookeeper配置的是127.0.0.1,请以真实ip为准
二、准备:
1. 安装zookeeper:
因为是演示,只安装一个zookeeper就好了,真实环境应该是集群。
2. 工程结构和依赖
<modules> <module>dubbo-train-provider</module> <module>dubbo-train-consumer</module> <module>dubbo-train-api</module> </modules> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <zookeeper>3.4.5</zookeeper> <curator.version>2.3.0</curator.version> <spring.version>3.2.5.RELEASE</spring.version> <slf4j.version>1.7.5</slf4j.version> <guava.version>15.0</guava.version> <dubbo.version>2.4.11</dubbo.version> <logback.version>1.0.13</logback.version> <javassist.version>3.18.2-GA</javassist.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>${logback.version}</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>${logback.version}</version> </dependency> <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>${zookeeper}</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> <exclusion> <groupId>jline</groupId> <artifactId>jline</artifactId> </exclusion> <exclusion> <groupId>org.jboss.netty</groupId> <artifactId>netty</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>${javassist.version}</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>${dubbo.version}</version> <exclusions> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> <exclusion> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> </exclusion> <exclusion> <groupId>org.apache.curator</groupId> <artifactId>curator-client</artifactId> </exclusion> <exclusion> <groupId>org.apache.curator</groupId> <artifactId>curator-recipes</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-recipes</artifactId> <version>${curator.version}</version> <exclusions> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-client</artifactId> <version>${curator.version}</version> <exclusions> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-framework</artifactId> <version>${curator.version}</version> <exclusions> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </exclusion> </exclusions> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> <includes> <include>**/*.*</include> </includes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <includes> <include>**/*.*</include> </includes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.3</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build>
3. logback配置:
<?xml version="1.0" encoding="UTF-8"?> <configuration scan="true" scanPeriod="5 seconds"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="INFO"> <appender-ref ref="STDOUT"/> </root> </configuration>
三、快速开始
1. api
(1) 定义视频信息服务接口:
package com.sohu.tv.dubbo.train.api; import com.sohu.tv.dubbo.train.api.bean.VideoInfo; /** * 视频信息接口 * * @author leifu * @Date 2016年2月15日 * @Time 下午3:14:48 */ public interface VideoService { /** * 通过视频id获取视频信息 * * @param id * @return */ VideoInfo get(long id); }
(2) 定义视频信息javabean:
package com.sohu.tv.dubbo.train.api.bean; import java.io.Serializable; /** * 视频信息bean * @author leifu * @Date 2016年2月15日 * @Time 下午3:16:19 */ public class VideoInfo implements Serializable { private static final long serialVersionUID = -3767840728003002950L; private long id; private String name; private String info; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getInfo() { return info; } public void setInfo(String info) { this.info = info; } @Override public String toString() { return "VideoInfo [id=" + id + ", name=" + name + ", info=" + info + "]"; } }
2. provider:
(1) 代码
(a) 视频信息服务实现类:
package com.sohu.tv.dubbo.train.provider.service.impl; import com.sohu.tv.dubbo.train.api.VideoService; import com.sohu.tv.dubbo.train.api.bean.VideoInfo; import com.sohu.tv.dubbo.train.provider.mock.RedisVideoInfoMock; /** * 视频信息实现 * @author leifu * @Date 2016年2月15日 * @Time 下午3:22:11 */ public class VideoServiceImpl implements VideoService { private RedisVideoInfoMock redisVideoInfoMock; @Override public VideoInfo get(long id) { return redisVideoInfoMock.get(id); } public void setRedisVideoInfoMock(RedisVideoInfoMock redisVideoInfoMock) { this.redisVideoInfoMock = redisVideoInfoMock; } }
(b) RedisVideoInfoMock是视频信息的Mock类:
package com.sohu.tv.dubbo.train.provider.mock; import com.sohu.tv.dubbo.train.api.bean.VideoInfo; /** * redisMock视频信息 * @author leifu * @Date 2016年2月15日 * @Time 下午3:23:50 */ public class RedisVideoInfoMock { /** * 通过id获取视频信息 * @param id * @return */ public VideoInfo get(long id) { VideoInfo videoInfo = new VideoInfo(); videoInfo.setId(id); videoInfo.setName("视频名:" + id); videoInfo.setInfo("视频描述:" + id); return videoInfo; } }
(c) 启动dubbo的provider:
package com.sohu.tv.dubbo.train.provider.main; /** * dubbo-provider Main * * @author leifu * @Date 2016年2月15日 * @Time 下午4:01:41 */ public class TrainProviderMain { public static void main(String[] args) { com.alibaba.dubbo.container.Main.main(args); } }
(2) 配置文件:
(a) dubbo.properties
dubbo.container=logback,spring dubbo.application.name=dubbo-train-provider dubbo.application.owner=leifu dubbo.application.logger=slf4j dubbo.registry.address=zookeeper://127.0.0.1:2181?client=curator dubbo.registry.timeout=8000 dubbo.protocol.name=dubbo dubbo.protocol.port=20880 dubbo.protocol.serialization=dubbo dubbo.protocol.threadpool=fixed dubbo.protocol.iothreads=17 dubbo.monitor.protocol=registry dubbo.spring.config=classpath*:spring/*.xml
(b) spring配置文件:dubbo-train-provider.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-autowire="byName"> <bean id="redisVideoInfoMock" class="com.sohu.tv.dubbo.train.provider.mock.RedisVideoInfoMock"/> <bean id="videoService" class="com.sohu.tv.dubbo.train.provider.service.impl.VideoServiceImpl" /> <dubbo:service interface="com.sohu.tv.dubbo.train.api.VideoService" ref="videoService" /> </beans>
(c) logback.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration scan="true" scanPeriod="5 seconds"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="INFO"> <appender-ref ref="STDOUT"/> </root> </configuration>
3.consumer
(1) 代码:
(a) videoService的消费者类:
package com.sohu.tv.dubbo.train.consumer.action; import java.util.Random; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.sohu.tv.dubbo.train.api.VideoService; import com.sohu.tv.dubbo.train.api.bean.VideoInfo; /** * 消费者 * @author leifu * @Date 2016年2月15日 * @Time 下午3:54:16 */ public class TrainConsumerAction { private Logger logger = LoggerFactory.getLogger(TrainConsumerAction.class); private VideoService videoService; public void start() throws Exception { while (true) { try { long id = new Random().nextLong(); VideoInfo videoInfo = videoService.get(id); System.out.println(videoInfo); logger.info(videoInfo.toString()); TimeUnit.SECONDS.sleep(1); } catch (Exception e) { e.printStackTrace(); } } } public void setVideoService(VideoService videoService) { this.videoService = videoService; } }
(b) dubbo消费者启动类:
package com.sohu.tv.dubbo.train.consumer.main; /** * dubbo-consumer开始 * * @author leifu * @Date 2016年2月15日 * @Time 下午4:01:15 */ public class TrainConsumerMain { public static void main(String[] args) { com.alibaba.dubbo.container.Main.main(args); } }
(2) 配置:
(a) dubbo.properties:
dubbo.container=logback,spring dubbo.application.name=dubbo-train-consumer dubbo.application.owner=carlosfu dubbo.application.logger=slf4j dubbo.registry.address=zookeeper://127.0.0.1:2181?client=curator dubbo.monitor.protocol=registry dubbo.spring.config=classpath*:spring/*.xml
(b) 消费者spring配置:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-autowire="byName"> <dubbo:reference id="videoService" interface="com.sohu.tv.dubbo.train.api.VideoService" /> <bean id="trainConsumerAction" class="com.sohu.tv.dubbo.train.consumer.action.TrainConsumerAction" init-method="start"></bean> </beans>
四、测试:
1.zookeeper有provider和consumer的节点:
2. consumer调用provider:
provider启动日志
17:55:49.283 [main] INFO c.a.d.common.logger.LoggerFactory - using logger: com.alibaba.dubbo.common.logger.slf4j.Slf4jLoggerAdapter 17:55:49.330 [main] INFO com.alibaba.dubbo.container.Main - [DUBBO] Use container type([logback, spring]) to run dubbo serivce., dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 17:55:49.330 [main] INFO com.alibaba.dubbo.container.Main - [DUBBO] Dubbo LogbackContainer started!, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 二月 15, 2016 5:55:49 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@511d9ca5: startup date [Mon Feb 15 17:55:49 CST 2016]; root of context hierarchy 二月 15, 2016 5:55:49 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from file [D:\git-project\dubbo-train\dubbo-train-provider\target\classes\spring\dubbo-train-provider.xml] 二月 15, 2016 5:55:49 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2d09c79b: defining beans [redisVideoInfoMock,videoService,com.sohu.tv.dubbo.train.api.VideoService]; root of factory hierarchy 17:55:49.849 [main] INFO c.a.dubbo.config.AbstractConfig - [DUBBO] The service ready on spring started. service: com.sohu.tv.dubbo.train.api.VideoService, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 17:55:49.854 [main] INFO c.a.d.common.logger.LoggerFactory - using logger: com.alibaba.dubbo.common.logger.slf4j.Slf4jLoggerAdapter 17:55:49.980 [main] INFO c.a.dubbo.config.AbstractConfig - [DUBBO] Export dubbo service com.sohu.tv.dubbo.train.api.VideoService to local registry, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 17:55:49.980 [main] INFO c.a.dubbo.config.AbstractConfig - [DUBBO] Export dubbo service com.sohu.tv.dubbo.train.api.VideoService to url dubbo://10.7.40.98:20880/com.sohu.tv.dubbo.train.api.VideoService?anyhost=true&application=dubbo-train-provider&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&iothreads=17&logger=slf4j&methods=get&owner=leifu&pid=87888&serialization=dubbo&side=provider&threadpool=fixed×tamp=1455530149876, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 17:55:49.982 [main] INFO c.a.dubbo.config.AbstractConfig - [DUBBO] Register dubbo service com.sohu.tv.dubbo.train.api.VideoService url dubbo://10.7.40.98:20880/com.sohu.tv.dubbo.train.api.VideoService?anyhost=true&application=dubbo-train-provider&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&iothreads=17&logger=slf4j&methods=get&monitor=dubbo%3A%2F%2F10.16.14.251%3A2181%2Fcom.alibaba.dubbo.registry.RegistryService%3Fapplication%3Ddubbo-train-provider%26client%3Dcurator%26dubbo%3D2.4.12a-SNAPSHOT%26logger%3Dslf4j%26owner%3Dleifu%26pid%3D87888%26protocol%3Dregistry%26refer%3Ddubbo%253D2.4.12a-SNAPSHOT%2526interface%253Dcom.alibaba.dubbo.monitor.MonitorService%2526pid%253D87888%2526timestamp%253D1455530149981%26registry%3Dzookeeper%26timeout%3D8000%26timestamp%3D1455530149867&owner=leifu&pid=87888&serialization=dubbo&side=provider&threadpool=fixed×tamp=1455530149876 to registry registry://10.16.14.251:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-train-provider&client=curator&dubbo=2.4.12a-SNAPSHOT&logger=slf4j&owner=leifu&pid=87888®istry=zookeeper&timeout=8000×tamp=1455530149867, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 17:55:50.171 [main] INFO c.a.d.r.transport.AbstractServer - [DUBBO] Start NettyServer bind /0.0.0.0:20880, export /10.7.40.98:20880, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 ........................... 17:55:50.262 [main] INFO o.a.c.f.imps.CuratorFrameworkImpl - Starting 17:55:50.269 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT 17:55:50.269 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:host.name=FULEI-TJ.sohu-inc.com 17:55:50.269 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.version=1.7.0_55 17:55:50.269 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.vendor=Oracle Corporation 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.home=C:\Program Files\Java\jdk1.7.0_55\jre 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.class.path=D:\git-project\dubbo-train\dubbo-train-provider\target\classes;D:\mavenRespo\respo\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;D:\mavenRespo\respo\ch\qos\logback\logback-core\1.0.13\logback-core-1.0.13.jar;D:\mavenRespo\respo\ch\qos\logback\logback-classic\1.0.13\logback-classic-1.0.13.jar;D:\mavenRespo\respo\org\apache\zookeeper\zookeeper\3.4.5\zookeeper-3.4.5.jar;D:\mavenRespo\respo\org\springframework\spring-tx\3.2.5.RELEASE\spring-tx-3.2.5.RELEASE.jar;D:\mavenRespo\respo\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\mavenRespo\respo\org\springframework\spring-core\3.2.5.RELEASE\spring-core-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-beans\3.2.5.RELEASE\spring-beans-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-expression\3.2.5.RELEASE\spring-expression-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-context\3.2.5.RELEASE\spring-context-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-aop\3.2.5.RELEASE\spring-aop-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-context-support\3.2.5.RELEASE\spring-context-support-3.2.5.RELEASE.jar;D:\mavenRespo\respo\com\google\guava\guava\15.0\guava-15.0.jar;D:\mavenRespo\respo\org\javassist\javassist\3.18.2-GA\javassist-3.18.2-GA.jar;D:\mavenRespo\respo\com\alibaba\dubbo\2.4.12a-SNAPSHOT\dubbo-2.4.12a-SNAPSHOT.jar;D:\mavenRespo\respo\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;D:\mavenRespo\respo\io\netty\netty\3.10.4.Final\netty-3.10.4.Final.jar;D:\mavenRespo\respo\com\caucho\hessian\4.0.7\hessian-4.0.7.jar;D:\mavenRespo\respo\jline\jline\0.9.94\jline-0.9.94.jar;D:\mavenRespo\respo\junit\junit\3.8.1\junit-3.8.1.jar;D:\mavenRespo\respo\org\apache\curator\curator-recipes\2.3.0\curator-recipes-2.3.0.jar;D:\mavenRespo\respo\org\apache\curator\curator-client\2.3.0\curator-client-2.3.0.jar;D:\mavenRespo\respo\org\apache\curator\curator-framework\2.3.0\curator-framework-2.3.0.jar;D:\git-project\dubbo-train\dubbo-train-api\target\classes 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.library.path=C:\Program Files\Java\jdk1.7.0_55\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\NetSarang;C:\Perl64\site\bin;C:\Perl64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_55\bin;d:\AppServ\MySQL\bin;C:\Python27;D:\maven-3.1.0\bin;C:\apache-ant-1.9.3\bin;. 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.io.tmpdir=C:\Users\leifu\AppData\Local\Temp\ 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.compiler=<NA> 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:os.name=Windows 7 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:os.arch=amd64 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:os.version=6.1 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:user.name=leifu 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:user.home=C:\Users\leifu 17:55:50.270 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:user.dir=D:\git-project\dubbo-train\dubbo-train-provider 17:55:50.271 [main] INFO org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=10.16.14.251:2181 sessionTimeout=60000 watcher=org.apache.curator.ConnectionState@7be97a62 17:55:50.287 [main] INFO c.a.d.r.zookeeper.ZookeeperRegistry - [DUBBO] Register: dubbo://10.7.40.98:20880/com.sohu.tv.dubbo.train.api.VideoService?anyhost=true&application=dubbo-train-provider&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&iothreads=17&logger=slf4j&methods=get&owner=leifu&pid=87888&serialization=dubbo&side=provider&threadpool=fixed×tamp=1455530149876, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 17:55:59.293 [main-SendThread(10.16.14.251:2181)] INFO org.apache.zookeeper.ClientCnxn - Opening socket connection to server 10.16.14.251/10.16.14.251:2181. Will not attempt to authenticate using SASL (unknown error) 17:55:59.307 [main-SendThread(10.16.14.251:2181)] INFO org.apache.zookeeper.ClientCnxn - Socket connection established to 10.16.14.251/10.16.14.251:2181, initiating session 17:55:59.326 [main-SendThread(10.16.14.251:2181)] INFO org.apache.zookeeper.ClientCnxn - Session establishment complete on server 10.16.14.251/10.16.14.251:2181, sessionid = 0x14bdeb5224b5431, negotiated timeout = 60000 17:55:59.329 [main-EventThread] INFO o.a.c.f.state.ConnectionStateManager - State change: CONNECTED 17:56:00.405 [main] INFO c.a.d.r.zookeeper.ZookeeperRegistry - [DUBBO] Subscribe: provider://10.7.40.98:20880/com.sohu.tv.dubbo.train.api.VideoService?anyhost=true&application=dubbo-train-provider&category=configurators&check=false&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&iothreads=17&logger=slf4j&methods=get&owner=leifu&pid=87888&serialization=dubbo&side=provider&threadpool=fixed×tamp=1455530149876, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 17:56:00.466 [main] INFO c.a.d.r.zookeeper.ZookeeperRegistry - [DUBBO] Notify urls for subscribe url provider://10.7.40.98:20880/com.sohu.tv.dubbo.train.api.VideoService?anyhost=true&application=dubbo-train-provider&category=configurators&check=false&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&iothreads=17&logger=slf4j&methods=get&owner=leifu&pid=87888&serialization=dubbo&side=provider&threadpool=fixed×tamp=1455530149876, urls: [empty://10.7.40.98:20880/com.sohu.tv.dubbo.train.api.VideoService?anyhost=true&application=dubbo-train-provider&category=configurators&check=false&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&iothreads=17&logger=slf4j&methods=get&owner=leifu&pid=87888&serialization=dubbo&side=provider&threadpool=fixed×tamp=1455530149876], dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 17:56:00.491 [main] INFO com.alibaba.dubbo.container.Main - [DUBBO] Dubbo SpringContainer started!, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 [2016-02-15 17:56:00] Dubbo service server started!
consumer启动日志:
17:56:30.375 [main] INFO c.a.d.common.logger.LoggerFactory - using logger: com.alibaba.dubbo.common.logger.slf4j.Slf4jLoggerAdapter 17:56:30.421 [main] INFO com.alibaba.dubbo.container.Main - [DUBBO] Use container type([logback, spring]) to run dubbo serivce., dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 17:56:30.421 [main] INFO com.alibaba.dubbo.container.Main - [DUBBO] Dubbo LogbackContainer started!, dubbo version: 2.4.12a-SNAPSHOT, current host: 127.0.0.1 二月 15, 2016 5:56:30 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@511d9ca5: startup date [Mon Feb 15 17:56:30 CST 2016]; root of context hierarchy 二月 15, 2016 5:56:30 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from file [D:\git-project\dubbo-train\dubbo-train-consumer\target\classes\spring\dubbo-train-consumer.xml] 二月 15, 2016 5:56:30 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2cdbf42e: defining beans [videoService,trainConsumerAction]; root of factory hierarchy 17:56:30.944 [main] INFO c.a.d.common.logger.LoggerFactory - using logger: com.alibaba.dubbo.common.logger.slf4j.Slf4jLoggerAdapter ..................... 17:56:31.088 [main] INFO o.a.c.f.imps.CuratorFrameworkImpl - Starting 17:56:31.095 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:host.name=FULEI-TJ.sohu-inc.com 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.version=1.7.0_55 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.vendor=Oracle Corporation 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.home=C:\Program Files\Java\jdk1.7.0_55\jre 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.class.path=D:\git-project\dubbo-train\dubbo-train-consumer\target\classes;D:\mavenRespo\respo\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;D:\mavenRespo\respo\ch\qos\logback\logback-core\1.0.13\logback-core-1.0.13.jar;D:\mavenRespo\respo\ch\qos\logback\logback-classic\1.0.13\logback-classic-1.0.13.jar;D:\mavenRespo\respo\org\apache\zookeeper\zookeeper\3.4.5\zookeeper-3.4.5.jar;D:\mavenRespo\respo\org\springframework\spring-tx\3.2.5.RELEASE\spring-tx-3.2.5.RELEASE.jar;D:\mavenRespo\respo\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\mavenRespo\respo\org\springframework\spring-core\3.2.5.RELEASE\spring-core-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-beans\3.2.5.RELEASE\spring-beans-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-expression\3.2.5.RELEASE\spring-expression-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-context\3.2.5.RELEASE\spring-context-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-aop\3.2.5.RELEASE\spring-aop-3.2.5.RELEASE.jar;D:\mavenRespo\respo\org\springframework\spring-context-support\3.2.5.RELEASE\spring-context-support-3.2.5.RELEASE.jar;D:\mavenRespo\respo\com\google\guava\guava\15.0\guava-15.0.jar;D:\mavenRespo\respo\org\javassist\javassist\3.18.2-GA\javassist-3.18.2-GA.jar;D:\mavenRespo\respo\com\alibaba\dubbo\2.4.12a-SNAPSHOT\dubbo-2.4.12a-SNAPSHOT.jar;D:\mavenRespo\respo\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;D:\mavenRespo\respo\io\netty\netty\3.10.4.Final\netty-3.10.4.Final.jar;D:\mavenRespo\respo\com\caucho\hessian\4.0.7\hessian-4.0.7.jar;D:\mavenRespo\respo\jline\jline\0.9.94\jline-0.9.94.jar;D:\mavenRespo\respo\junit\junit\3.8.1\junit-3.8.1.jar;D:\mavenRespo\respo\org\apache\curator\curator-recipes\2.3.0\curator-recipes-2.3.0.jar;D:\mavenRespo\respo\org\apache\curator\curator-client\2.3.0\curator-client-2.3.0.jar;D:\mavenRespo\respo\org\apache\curator\curator-framework\2.3.0\curator-framework-2.3.0.jar;D:\git-project\dubbo-train\dubbo-train-api\target\classes 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.library.path=C:\Program Files\Java\jdk1.7.0_55\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\NetSarang;C:\Perl64\site\bin;C:\Perl64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_55\bin;d:\AppServ\MySQL\bin;C:\Python27;D:\maven-3.1.0\bin;C:\apache-ant-1.9.3\bin;. 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.io.tmpdir=C:\Users\leifu\AppData\Local\Temp\ 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:java.compiler=<NA> 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:os.name=Windows 7 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:os.arch=amd64 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:os.version=6.1 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:user.name=leifu 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:user.home=C:\Users\leifu 17:56:31.096 [main] INFO org.apache.zookeeper.ZooKeeper - Client environment:user.dir=D:\git-project\dubbo-train\dubbo-train-consumer 17:56:31.097 [main] INFO org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=10.16.14.251:2181 sessionTimeout=60000 watcher=org.apache.curator.ConnectionState@1038aa1e 17:56:31.152 [main] INFO c.a.d.r.zookeeper.ZookeeperRegistry - [DUBBO] Register: consumer://10.7.40.98/com.sohu.tv.dubbo.train.api.VideoService?application=dubbo-train-consumer&category=consumers&check=false&connected=false&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&logger=slf4j&methods=get&owner=carlosfu&pid=92868&side=consumer×tamp=1455530190945, dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:40.136 [main-SendThread(10.16.14.251:2181)] INFO org.apache.zookeeper.ClientCnxn - Opening socket connection to server 10.16.14.251/10.16.14.251:2181. Will not attempt to authenticate using SASL (unknown error) 17:56:40.150 [main-SendThread(10.16.14.251:2181)] INFO org.apache.zookeeper.ClientCnxn - Socket connection established to 10.16.14.251/10.16.14.251:2181, initiating session 17:56:40.172 [main-SendThread(10.16.14.251:2181)] INFO org.apache.zookeeper.ClientCnxn - Session establishment complete on server 10.16.14.251/10.16.14.251:2181, sessionid = 0x14bdeb5224b5432, negotiated timeout = 60000 17:56:40.176 [main-EventThread] INFO o.a.c.f.state.ConnectionStateManager - State change: CONNECTED 17:56:41.255 [main] INFO c.a.d.r.zookeeper.ZookeeperRegistry - [DUBBO] Subscribe: consumer://10.7.40.98/com.sohu.tv.dubbo.train.api.VideoService?application=dubbo-train-consumer&category=providers,configurators,routers&connected=false&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&logger=slf4j&methods=get&owner=carlosfu&pid=92868&side=consumer×tamp=1455530190945, dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:41.428 [main] INFO c.a.d.r.zookeeper.ZookeeperRegistry - [DUBBO] Notify urls for subscribe url consumer://10.7.40.98/com.sohu.tv.dubbo.train.api.VideoService?application=dubbo-train-consumer&category=providers,configurators,routers&connected=false&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&logger=slf4j&methods=get&owner=carlosfu&pid=92868&side=consumer×tamp=1455530190945, urls: [dubbo://10.7.40.98:20880/com.sohu.tv.dubbo.train.api.VideoService?anyhost=true&application=dubbo-train-provider&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&iothreads=17&logger=slf4j&methods=get&owner=leifu&pid=87888&serialization=dubbo&side=provider&threadpool=fixed×tamp=1455530149876, empty://10.7.40.98/com.sohu.tv.dubbo.train.api.VideoService?application=dubbo-train-consumer&category=configurators&connected=false&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&logger=slf4j&methods=get&owner=carlosfu&pid=92868&side=consumer×tamp=1455530190945, empty://10.7.40.98/com.sohu.tv.dubbo.train.api.VideoService?application=dubbo-train-consumer&category=routers&connected=false&dubbo=2.4.12a-SNAPSHOT&interface=com.sohu.tv.dubbo.train.api.VideoService&logger=slf4j&methods=get&owner=carlosfu&pid=92868&side=consumer×tamp=1455530190945], dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:41.575 [main] INFO c.a.d.r.transport.AbstractClient - [DUBBO] Successed connect to server /10.7.40.98:20880 from NettyClient 10.7.40.98 using dubbo version 2.4.12a-SNAPSHOT, channel is NettyChannel [channel=[id: 0x5b078ade, /10.7.40.98:56957 => /10.7.40.98:20880]], dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:41.575 [main] INFO c.a.d.r.transport.AbstractClient - [DUBBO] Start NettyClient FULEI-TJ/10.7.40.98 connect to the server /10.7.40.98:20880, dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:41.627 [main] INFO c.a.dubbo.config.AbstractConfig - [DUBBO] Refer dubbo service com.sohu.tv.dubbo.train.api.VideoService from url zookeeper://10.16.14.251:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=dubbo-train-consumer&check=false&connected=true&dubbo=2.4.12a-SNAPSHOT&inside.invoker.count=1&inside.invokers=dubbo%3A%2F%2F10.7.40.98%3A20880%2Fcom.sohu.tv.dubbo.train.api.VideoService%3Fanyhost%3Dtrue%26application%3Ddubbo-train-provider%26dubbo%3D2.4.12a-SNAPSHOT%26interface%3Dcom.sohu.tv.dubbo.train.api.VideoService%26iothreads%3D17%26logger%3Dslf4j%26methods%3Dget%26owner%3Dleifu%26pid%3D87888%26serialization%3Ddubbo%26side%3Dprovider%26threadpool%3Dfixed%26timestamp%3D1455530149876&interface=com.sohu.tv.dubbo.train.api.VideoService&iothreads=17&logger=slf4j&methods=get&monitor=dubbo%3A%2F%2F10.16.14.251%3A2181%2Fcom.alibaba.dubbo.registry.RegistryService%3Fapplication%3Ddubbo-train-consumer%26client%3Dcurator%26dubbo%3D2.4.12a-SNAPSHOT%26logger%3Dslf4j%26owner%3Dcarlosfu%26pid%3D92868%26protocol%3Dregistry%26refer%3Ddubbo%253D2.4.12a-SNAPSHOT%2526interface%253Dcom.alibaba.dubbo.monitor.MonitorService%2526pid%253D92868%2526timestamp%253D1455530190985%26registry%3Dzookeeper%26timestamp%3D1455530190980&owner=carlosfu&pid=92868&serialization=dubbo&side=consumer×tamp=1455530190945, dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:42.004 [main] INFO c.a.d.r.zookeeper.ZookeeperRegistry - [DUBBO] Register: consumer://10.7.40.98/com.alibaba.dubbo.monitor.MonitorService?category=consumers&check=false&connected=true&dubbo=2.4.12a-SNAPSHOT&interface=com.alibaba.dubbo.monitor.MonitorService&pid=92868×tamp=1455530190985, dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:42.056 [main] INFO c.a.d.r.zookeeper.ZookeeperRegistry - [DUBBO] Subscribe: consumer://10.7.40.98/com.alibaba.dubbo.monitor.MonitorService?category=providers,configurators,routers&connected=true&dubbo=2.4.12a-SNAPSHOT&interface=com.alibaba.dubbo.monitor.MonitorService&pid=92868×tamp=1455530190985, dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:42.217 [main] INFO c.a.d.r.zookeeper.ZookeeperRegistry - [DUBBO] Notify urls for subscribe url consumer://10.7.40.98/com.alibaba.dubbo.monitor.MonitorService?category=providers,configurators,routers&connected=true&dubbo=2.4.12a-SNAPSHOT&interface=com.alibaba.dubbo.monitor.MonitorService&pid=92868×tamp=1455530190985, urls: [dubbo://10.16.14.153:6060/com.alibaba.dubbo.monitor.MonitorService?anyhost=true&application=dubbo-monitor&delay=-1&dubbo=2.4.12a-SNAPSHOT&interface=com.alibaba.dubbo.monitor.MonitorService&methods=lookup,collect&owner=leifu&pid=24004&revision=2.4.12a-SNAPSHOT&side=provider×tamp=1453775541485, empty://10.7.40.98/com.alibaba.dubbo.monitor.MonitorService?category=configurators&connected=true&dubbo=2.4.12a-SNAPSHOT&interface=com.alibaba.dubbo.monitor.MonitorService&pid=92868×tamp=1455530190985, empty://10.7.40.98/com.alibaba.dubbo.monitor.MonitorService?category=routers&connected=true&dubbo=2.4.12a-SNAPSHOT&interface=com.alibaba.dubbo.monitor.MonitorService&pid=92868×tamp=1455530190985], dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:42.225 [main] INFO c.a.d.r.transport.AbstractClient - [DUBBO] Successed connect to server /10.16.14.153:6060 from NettyClient 10.7.40.98 using dubbo version 2.4.12a-SNAPSHOT, channel is NettyChannel [channel=[id: 0x5cf6ee92, /10.7.40.98:56971 => /10.16.14.153:6060]], dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 17:56:42.225 [main] INFO c.a.d.r.transport.AbstractClient - [DUBBO] Start NettyClient FULEI-TJ/10.7.40.98 connect to the server /10.16.14.153:6060, dubbo version: 2.4.12a-SNAPSHOT, current host: 10.7.40.98 VideoInfo [id=1571379734545151673, name=视频名:1571379734545151673, info=视频描述:1571379734545151673] 17:56:42.233 [main] INFO c.s.t.d.t.c.a.TrainConsumerAction - VideoInfo [id=1571379734545151673, name=视频名:1571379734545151673, info=视频描述:1571379734545151673] VideoInfo [id=-8451105473690279115, name=视频名:-8451105473690279115, info=视频描述:-8451105473690279115] 17:56:43.236 [main] INFO c.s.t.d.t.c.a.TrainConsumerAction - VideoInfo [id=-8451105473690279115, name=视频名:-8451105473690279115, info=视频描述:-8451105473690279115] VideoInfo [id=5227312763746681516, name=视频名:5227312763746681516, info=视频描述:5227312763746681516] 17:56:44.239 [main] INFO c.s.t.d.t.c.a.TrainConsumerAction - VideoInfo [id=5227312763746681516, name=视频名:5227312763746681516, info=视频描述:5227312763746681516] VideoInfo [id=37036120943992274, name=视频名:37036120943992274, info=视频描述:37036120943992274] 17:56:45.241 [main] INFO c.s.t.d.t.c.a.TrainConsumerAction - VideoInfo [id=37036120943992274, name=视频名:37036120943992274, info=视频描述:37036120943992274] VideoInfo [id=-2092250957867316795, name=视频名:-2092250957867316795, info=视频描述:-2092250957867316795] 17:56:46.244 [main] INFO c.s.t.d.t.c.a.TrainConsumerAction - VideoInfo [id=-2092250957867316795, name=视频名:-2092250957867316795, info=视频描述:-2092250957867316795] VideoInfo [id=-636500617330674946, name=视频名:-636500617330674946, info=视频描述:-636500617330674946] 17:56:47.247 [main] INFO c.s.t.d.t.c.a.TrainConsumerAction - VideoInfo [id=-636500617330674946, name=视频名:-636500617330674946, info=视频描述:-636500617330674946] VideoInfo [id=-3676813828951475060, name=视频名:-3676813828951475060, info=视频描述:-3676813828951475060] 17:56:48.250 [main] INFO c.s.t.d.t.c.a.TrainConsumerAction - VideoInfo [id=-3676813828951475060, name=视频名:-3676813828951475060, info=视频描述:-3676813828951475060]