Service Multiplexing using Apache Thrift

耗尽温柔 提交于 2019-12-01 07:36:06
JensG

Not tested, but it looks very much like as if you run two different protocol stacks on server and client. Try this:

TMultiplexedProcessor processor = new TMultiplexedProcessor();

processor.registerProcessor(
    "AddService",
    new AddService.Processor(new AddHandler()));

processor.registerProcessor(
    "MultiplyService",
    new MultiplyService.Processor(new MultiplyHandler()));

TServerTransport serverTransport = new TServerSocket(7911);

TTransportFactory factory = new TFramedTransport.Factory();

TServer.Args args = new TServer.Args(serverTransport);
args.processor(processor);
args.transportFactory(factory);
TSimpleServer server = new TSimpleServer(args);

System.out.println("Starting server on port 7911 ...");
server.serve();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!