List of usage examples for org.apache.thrift.protocol TTupleProtocol writeMessageBegin
@Override public void writeMessageBegin(TMessage message) throws TException
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 {//from www . ja v a 2s . co m 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()); } }