Apache Thrift tuck client when working with two clients - how to make server multitasking?

I am running the Apache Thrift tutorial for Java .

When two client processes start simultaneously, the server does not accept the second client. Only after the first client finishes, the second will be accepted by the server.

Can someone explain what is happening?

How can I make the server accept multiple connections in multiple threads?

+4
source share
2 answers

Can someone explain what is happening?

You’ve already found out: TSimpleServerit allows you to use only one connection at a time. It will be available again when the first client disconnects.

?

, ,

, , TFramedTransport.

+2

, .

():

CalculatorHandler handler = new CalculatorHandler();
Calculator.Processor processor = new Calculator.Processor(handler);
TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(9090);
THsHaServer.Args args = new THsHaServer.Args(serverTransport);
args.processor(processor);
args.transportFactory(new TFramedTransport.Factory());
TServer server = new THsHaServer(args);
server.serve();

:

transport = new TSocket("localhost", 9090);
transport.open();
TProtocol protocol = new  TBinaryProtocol(new TFramedTransport(transport));
Calculator.Client client = new Calculator.Client(protocol);
perform(client);
+1

All Articles