标签:
1.下载对应的thrift客户端 编写test.thrift参数 将客户端exe文件盒test.thrift文件放在同一个地方 生成service (thrift-0.9.2.exe --gen java test.thrift)
ps 生成service过程
1.
  
  2.
3.生成的列表
     
4.将生成的service复制到对应项目中
  
5.实现TestService接口
6.编写服务端
public void start() {
		new Thread() {
			public void run() {
				try {
					// 设置服务端口为 7911
					TServerSocket serverTransport = new TServerSocket(8889);
					// 设置协议工厂为 TBinaryProtocol.Factory
					Factory proFactory = new TBinaryProtocol.Factory();
					// 关联处理器与 Sms 服务的实现
					TProcessor processor = new TestService.Processor<TestServiceImpl>(
TestService);
					Args args = new Args(serverTransport);
					args.processor(processor);
					args.protocolFactory(proFactory);
					TServer server = new TThreadPoolServer(args);
					System.out.println("Start server on port 7911...");
					server.serve();
				} catch (TTransportException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}.start();
	}
服务端就建成了
客户端稍后补充
标签:
原文地址:http://www.cnblogs.com/hayyah/p/4273069.html