Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1915 Multiplexing Services
  3. THRIFT-66

Java: Allow multiplexing multiple services over a single TCP connection



    • Patch Available


      The current TServer implementations expose a single service on a port. If an application has many services many ports have to be opened. This is cumbersome because:

      • you have to document which service is available on which port, and remembering the port numbers is difficult
      • to prevent the overhead of connection setup on each call, a client has to maintain to many connections: at least one to each port
      • it requires opening many ports on a firewall if one is between the client and the server.

      By multiplexing multiple services on a single port the problems above are resolved:

      • instead of a port number a symbolic name can be assigned to a service
      • a client can maintain a small pool of connections to a single port
      • only one port has to be opened on the firewall

      The attached Java implementation simply wraps a normal CALL message with a (new) SERVICE_SELECTION message. It is not necessary to modify or wrap the response. No changes are needed to the generated classes. Only a new type of server is introduced, and an invocation handler for a dynamic proxy around the Client classes of services is provided for the client side. The implementation does not handle communication errors (invalid data, timeouts, etc.) yet.


        1. CalculatorImpl.java
          2 kB
          Johan Stuyts
        2. MultiplexTestClientMain.java
          3 kB
          Johan Stuyts
        3. MultiplexTestServerMain.java
          1 kB
          Johan Stuyts
        4. SharedImpl.java
          0.5 kB
          Johan Stuyts
        5. ThriftMultiplexInvocationHandler.java
          2 kB
          Johan Stuyts
        6. TMultiplexServer.java
          3 kB
          Johan Stuyts
        7. TSimpleMultiplexServer.java
          5 kB
          Johan Stuyts
        8. TMultiplexServer.py
          14 kB
        9. Thrift Endpoints and Channels.vsd
          141 kB
          James E. King III
        10. ThriftCSharpEndpointsChannels.zip
          264 kB
          James E. King III
        11. ReleaseWaitingReplyThreadsOnDisconnect.patch
          2 kB
          James E. King III

        Issue Links



              roger Roger Meier
              jstuyts Johan Stuyts
              13 Vote for this issue
              13 Start watching this issue