Search in sources :

Example 1 with RequestMessageProcessor

use of org.apache.eventmesh.runtime.core.protocol.grpc.processor.RequestMessageProcessor in project incubator-eventmesh by apache.

the class ProducerService method requestReply.

public void requestReply(SimpleMessage request, StreamObserver<SimpleMessage> responseObserver) {
    cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", "RequestReply", EventMeshConstants.PROTOCOL_GRPC, request.getHeader().getIp(), eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp);
    EventEmitter<SimpleMessage> emitter = new EventEmitter<>(responseObserver);
    threadPoolExecutor.submit(() -> {
        RequestMessageProcessor requestMessageProcessor = new RequestMessageProcessor(eventMeshGrpcServer);
        try {
            requestMessageProcessor.process(request, emitter);
        } catch (Exception e) {
            logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_REQUEST_REPLY_MSG_ERR.getRetCode(), StatusCode.EVENTMESH_REQUEST_REPLY_MSG_ERR.getErrMsg(), e);
            ServiceUtils.sendStreamRespAndDone(request.getHeader(), StatusCode.EVENTMESH_REQUEST_REPLY_MSG_ERR, e.getMessage(), emitter);
        }
    });
}
Also used : SimpleMessage(org.apache.eventmesh.common.protocol.grpc.protos.SimpleMessage) RequestMessageProcessor(org.apache.eventmesh.runtime.core.protocol.grpc.processor.RequestMessageProcessor)

Aggregations

SimpleMessage (org.apache.eventmesh.common.protocol.grpc.protos.SimpleMessage)1 RequestMessageProcessor (org.apache.eventmesh.runtime.core.protocol.grpc.processor.RequestMessageProcessor)1