Example usage for org.apache.thrift.protocol TTupleProtocol writeMessageEnd

List of usage examples for org.apache.thrift.protocol TTupleProtocol writeMessageEnd

Introduction

In this page you can find the example usage for org.apache.thrift.protocol TTupleProtocol writeMessageEnd.

Prototype

public void writeMessageEnd() throws TException 

Source Link

Usage

From source file:net.morimekta.providence.thrift.TTupleProtocolSerializer.java

License:Apache License

@Override
public <Message extends PMessage<Message, Field>, Field extends PField> int serialize(OutputStream output,
        PServiceCall<Message, Field> call) throws IOException {
    CountingOutputStream wrapper = new CountingOutputStream(output);
    TTransport transport = new TIOStreamTransport(wrapper);
    try {/*w  w w.  j av  a 2 s  .c  om*/
        TTupleProtocol protocol = (TTupleProtocol) protocolFactory.getProtocol(transport);
        TMessage tm = new TMessage(call.getMethod(), (byte) call.getType().getValue(), call.getSequence());

        protocol.writeMessageBegin(tm);
        writeMessage(call.getMessage(), protocol);
        protocol.writeMessageEnd();

        transport.flush();
        wrapper.flush();
        return wrapper.getByteCount();
    } catch (TException e) {
        throw new SerializerException(e, e.getMessage());
    }
}