Package org.apache.thrift.protocol
Class TMultiplexedProtocol
java.lang.Object
org.apache.thrift.protocol.TProtocol
org.apache.thrift.protocol.TProtocolDecorator
org.apache.thrift.protocol.TMultiplexedProtocol
- All Implemented Interfaces:
TReadProtocol,TWriteProtocol
TMultiplexedProtocol is a protocol-independent concrete decorator that allows a
Thrift client to communicate with a multiplexing Thrift server, by prepending the service name to
the function name during function calls.
NOTE: THIS IS NOT USED BY SERVERS. On the server, use TMultiplexedProcessor to handle requests from a
multiplexing client.
This example uses a single socket transport to invoke two services:
TSocket transport = new TSocket("localhost", 9090);
transport.open();
TBinaryProtocol protocol = new TBinaryProtocol(transport);
TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, "Calculator");
Calculator.Client service = new Calculator.Client(mp);
TMultiplexedProtocol mp2 = new TMultiplexedProtocol(protocol, "WeatherReport");
WeatherReport.Client service2 = new WeatherReport.Client(mp2);
System.out.println(service.add(2,2));
System.out.println(service2.getTemperature());
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.thrift.protocol.TProtocol
TProtocol.ReadCallback<T,R>, TProtocol.ReadCollectionCallback<R>, TProtocol.ReadMapEntryCallback<K, V>, TProtocol.WriteCallback<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringUsed to delimit the service name from the function nameFields inherited from class org.apache.thrift.protocol.TProtocol
skippedBytes, trans_ -
Constructor Summary
ConstructorsConstructorDescriptionTMultiplexedProtocol(TProtocol protocol, String serviceName) Wrap the specified protocol, allowing it to be used to communicate with a multiplexing server. -
Method Summary
Modifier and TypeMethodDescriptionvoidwriteMessageBegin(TMessage tMessage) Prepends the service name to the function name, separated by TMultiplexedProtocol.SEPARATOR.Methods inherited from class org.apache.thrift.protocol.TProtocolDecorator
getMinSerializedSize, readBinary, readBool, readByte, readDouble, readFieldBegin, readFieldEnd, readI16, readI32, readI64, readListBegin, readListEnd, readMapBegin, readMapEnd, readMessageBegin, readMessageEnd, readSetBegin, readSetEnd, readString, readStructBegin, readStructEnd, readUuid, writeBinary, writeBool, writeByte, writeDouble, writeFieldBegin, writeFieldEnd, writeFieldStop, writeI16, writeI32, writeI64, writeListBegin, writeListEnd, writeMapBegin, writeMapEnd, writeMessageEnd, writeSetBegin, writeSetEnd, writeString, writeStructBegin, writeStructEnd, writeUuidMethods inherited from class org.apache.thrift.protocol.TProtocol
checkReadBytesAvailable, checkReadBytesAvailable, checkReadBytesAvailable, getScheme, getTransport, readField, readFieldBeginData, readList, readList, readList, readMap, readMap, readMap, readMessage, readSet, readSet, readSet, readStruct, reset, skip, skip, skipBinary, skipBool, skipByte, skipBytes, skipDouble, skipI16, skipI32, skipI64, writeField, writeList, writeMap, writeMessage, writeSet, writeStruct
-
Field Details
-
SEPARATOR
Used to delimit the service name from the function name- See Also:
-
-
Constructor Details
-
TMultiplexedProtocol
Wrap the specified protocol, allowing it to be used to communicate with a multiplexing server. TheserviceNameis required as it is prepended to the message header so that the multiplexing server can broker the function call to the proper service.- Parameters:
protocol- Your communication protocol of choice, e.g.TBinaryProtocol.serviceName- The service name of the service communicating via this protocol.
-
-
Method Details
-
writeMessageBegin
Prepends the service name to the function name, separated by TMultiplexedProtocol.SEPARATOR.- Specified by:
writeMessageBeginin interfaceTWriteProtocol- Overrides:
writeMessageBeginin classTProtocolDecorator- Parameters:
tMessage- The original message.- Throws:
TException- Passed through from wrappedTProtocolinstance.
-