当前位置: 首页 > news >正文

做网站软件 手机新闻发布稿

做网站软件 手机,新闻发布稿,自己公司产品网站的好处,海淘手表网站当我们使用Thrift 通信的时候,服务端有时候需要注册多个类,去实现通信,这时候我们就不能再使用单一Processor的方式,就要使用多个Processor,那么如何去实现呢? 多个Process 服务端 public static void m…

当我们使用Thrift 通信的时候,服务端有时候需要注册多个类,去实现通信,这时候我们就不能再使用单一Processor的方式,就要使用多个Processor,那么如何去实现呢?

多个Process

服务端

public static void main(String[] args) {try {AImpl aService = new AImpl();BImpl bService=new BImpl();TMultiplexedProcessor multiplexedProcessor = new TMultiplexedProcessor();AService.Processor<AImpl> aProcessor = new AService.Processor<>(aService);multiplexedProcessor.registerProcessor("aService", aProcessor);BService.Processor<BImpl> bProcessor = new BService.Processor<>(bService);multiplexedProcessor.registerProcessor("bService", bProcessor);TServerSocket serverTransport = new TServerSocket(80000);TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);serverArgs.processor(multiplexedProcessor);TServer server = new TThreadPoolServer(serverArgs);System.out.println("Starting the multi-processor server...");server.serve();} catch (Exception e) {e.printStackTrace();System.out.println(e.getMessage());}}

客户端

public static void main(String[] args) throws TException {TTransport transport = new TSocket("localhost", 80000);transport.open();// AServiceTMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(new TBinaryProtocol(transport), "aService");AService.Client aClient = new AService.Client(multiplexedProtocol);aClient.method();System.out.println("Calling AService method...");// BServicemultiplexedProtocol = new TMultiplexedProtocol(new TBinaryProtocol(transport), "bService");BService.Client bClient = new BService.Client(multiplexedProtocol);BClient.method();System.out.println("Calling SystemLogService method...");transport.close();}

这个Demo中,我们要用到两个接口类,那么,A和B,使用TMultiplexedProcessor 去注册两个Service,启动服务。

单个Process

服务端

            AImpl aService = new AImpl();TServerSocket serverSocket = new TServerSocket(90000);AService.Processor<AImpl> aProcessor= new AService.Processor<>(aService);TThreadPoolServer.Args serverArg = new TThreadPoolServer.Args(serverSocket);serverArg.processor(aProcessor);TThreadPoolServer server = new TThreadPoolServer(serverArg);server.serve();

客户端

 TTransport transport = new TSocket("localhost", 90000);transport.open();TBinaryProtocol protocol = new TBinaryProtocol(transport);AService.Client aClient = new AService.Client(protocol);aclient.method();

附单个process的方式。

http://www.15wanjia.com/news/7063.html

相关文章:

  • 做门户网站的公司有哪些宝塔没有域名直接做网站怎么弄
  • 帮别人做彩票网站新闻联播直播 今天
  • 手机wap网站 php营销手段和技巧
  • 网站建设 司法公开的需要seo排名课程咨询电话
  • 旅游网站设计成都网站优化及推广
  • php做电商网站安全性如何软文广告范例大全
  • 网站外包后呗百度降权网站模板建站
  • 网站同步到新浪微博bt最佳磁力搜索引擎吧
  • 网站建设费计入什么科目百度的广告怎么免费发布
  • 网站建设备案长沙疫情最新消息今天封城了
  • 推荐昆明做网站建设校园推广
  • 福州电子网站建设上海广告推广
  • 做网站啦代理的方法文员短期电脑培训
  • 公司网站转微信小程序盘多多搜索引擎入口
  • 上海做网站比较好的公司有哪些竞价推广托管公司价格
  • 成功案例北京seo招聘
  • 做网站还是自媒体更适合赚钱短信广告投放
  • 织梦网站采集侠怎么做seo指的是
  • 头条站长平台电脑培训网
  • 网站安全风险提示单网推软件有哪些
  • 开源的 二次网站开发seo能干一辈子吗
  • 苏州建设交通职业学校优化设计卷子答案
  • 网站虚拟主机哪个好搜索引擎seo
  • 做阀门网站效果怎么样搜索引擎优化的分类
  • 网站建设不开单seo优化信
  • 那个网站可以做考卷网络整合营销案例
  • 大数据比赛网站建设买链接网站
  • 织梦做的网站织梦修改网页模板新闻投稿
  • 计算机应用技术网站开发基础知识网络营销软件下载
  • 网站建设与制作价格昆明网络营销