Package ola.rpc.Rpc

Examples of ola.rpc.Rpc.RpcMessage


    public void callMethod(MethodDescriptor method, RpcController controller,
            Message requestMessage, Message responseMessage, RpcCallback<Message> done) {

        int messageId = sequence++;

        RpcMessage message = RpcMessage.newBuilder()
                .setType(Rpc.Type.REQUEST)
                .setId(messageId)
                .setName(method.getName())
                .setBuffer(requestMessage.toByteString())
                .build();

        try {

            sendMessage(message);
            if (responseMessage.getDescriptorForType().getName().equals("STREAMING_NO_RESPONSE")) {
                // don't wait for response on streaming messages..
                return;
            }

            RpcMessage response = readMessage();

            if (response.getType().equals(Rpc.Type.RESPONSE)) {
                if (response.getId() != messageId) {
                    controller.setFailed("Received message with id " + response.getId() + " , but was expecting " + messageId);
                } else {
                    responseMessage = DynamicMessage.parseFrom(responseMessage.getDescriptorForType(), response.getBuffer());
                    if (done != null) {
                        done.run(responseMessage);
                    }
                }
            } else {
View Full Code Here

TOP

Related Classes of ola.rpc.Rpc.RpcMessage

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.