Package org.apache.thrift.protocol

Examples of org.apache.thrift.protocol.TMessage


                                                "Internal error processing " + method.getName());
                    applicationException.initCause(e);
                    LOG.error("Internal error processing {}", method.getName(), e);

                    // Application exceptions are sent to client, and the connection can be reused
                    out.writeMessageBegin(new TMessage(name, TMessageType.EXCEPTION, sequenceId));
                    applicationException.write(out);
                    out.writeMessageEnd();
                    out.getTransport().flush();

                    contextChain.postWriteException(methodName, applicationException);
View Full Code Here


                                   byte responseType,
                                   String responseFieldName,
                                   short responseFieldId,
                                   ThriftCodec<T> responseCodec,
                                   T result) throws Exception {
        out.writeMessageBegin(new TMessage(name, responseType, sequenceId));

        TProtocolWriter writer = new TProtocolWriter(out);
        writer.writeStructBegin(resultStructName);
        writer.writeField(responseFieldName, (short) responseFieldId, responseCodec, result);
        writer.writeStructEnd();
View Full Code Here

    {
        // Note that though setting message type to ONEWAY can be helpful when looking at packet
        // captures, some clients always send CALL and so servers are forced to rely on the "oneway"
        // attribute on thrift method in the interface definition, rather than checking the message
        // type.
        out.writeMessageBegin(new TMessage(name, oneway ? ONEWAY : CALL, sequenceId));

        // write the parameters
        TProtocolWriter writer = new TProtocolWriter(out);
        writer.writeStructBegin(name + "_args");
        for (int i = 0; i < args.length; i++) {
View Full Code Here

    }

    private void waitForResponse(TProtocol in, int sequenceId)
            throws TException
    {
        TMessage message = in.readMessageBegin();
        if (message.type == EXCEPTION) {
            TApplicationException exception = TApplicationException.read(in);
            in.readMessageEnd();
            throw exception;
        }
View Full Code Here

    @Override
    @SuppressWarnings("PMD.EmptyCatchBlock")
    public boolean process(TProtocol in, TProtocol out, RequestContext requestContext)
            throws TException
    {
        TMessage message = in.readMessageBegin();
        String methodName = message.name;
        int sequenceId = message.seqid;

        try {
            // lookup method
View Full Code Here

    private void writeTestMessages(TBinaryProtocol protocol, int count)
            throws TException
    {
        for (int i = 0; i < count; i++) {
            protocol.writeMessageBegin(new TMessage("testmessage" + i, TMessageType.CALL, i));
            {
                protocol.writeStructBegin(new TStruct());
                {
                    protocol.writeFieldBegin(new TField("i32field", TType.I32, (short) 1));
                    protocol.writeI32(123);
View Full Code Here

    private <T extends TTransport> T writeFirstChunk(T outTransport) throws TException
    {
        TProtocol outProtocol = new TBinaryProtocol(outTransport);

        outProtocol.writeMessageBegin(new TMessage());
        outProtocol.writeString("hello world");

        return outTransport;
    }
View Full Code Here

    {
        try {
            messageBuffer.markReaderIndex();
            TTransport inputTransport = new TChannelBufferInputTransport(messageBuffer);
            TProtocol inputProtocol = getProtocolFactory().getInputProtocolFactory().getProtocol(inputTransport);
            TMessage message = inputProtocol.readMessageBegin();
            messageBuffer.resetReaderIndex();
            return message.seqid;
        } catch (Throwable t) {
            throw new TTransportException("Could not find sequenceId in Thrift message");
        }
View Full Code Here

    {
        try {
            messageBuffer.markReaderIndex();
            TTransport inputTransport = new TChannelBufferInputTransport(messageBuffer);
            TProtocol inputProtocol = getProtocolFactory().getInputProtocolFactory().getProtocol(inputTransport);
            TMessage message = inputProtocol.readMessageBegin();
            messageBuffer.resetReaderIndex();
            return message.seqid;
        } catch (Throwable t) {
            throw new TTransportException("Could not find sequenceId in Thrift message");
        }
View Full Code Here

                                                              "Internal error processing " + method.getName());
                            applicationException.initCause(t);
                            LOG.error("Internal error processing {}", method.getName(), t);

                            // Application exceptions are sent to client, and the connection can be reused
                            out.writeMessageBegin(new TMessage(name, TMessageType.EXCEPTION, sequenceId));
                            applicationException.write(out);
                            out.writeMessageEnd();
                            out.getTransport().flush();

                            contextChain.postWriteException(applicationException);
View Full Code Here

TOP

Related Classes of org.apache.thrift.protocol.TMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.