use of org.apache.eventmesh.common.protocol.grpc.protos.Response in project incubator-eventmesh by apache.
the class HeartbeatService method heartbeat.
public void heartbeat(Heartbeat request, StreamObserver<Response> responseObserver) {
logger.info("cmd={}|{}|client2eventMesh|from={}|to={}", "heartbeat", EventMeshConstants.PROTOCOL_GRPC, request.getHeader().getIp(), eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp);
EventEmitter<Response> emitter = new EventEmitter<>(responseObserver);
threadPoolExecutor.submit(() -> {
HeartbeatProcessor heartbeatProcessor = new HeartbeatProcessor(eventMeshGrpcServer);
try {
heartbeatProcessor.process(request, emitter);
} catch (Exception e) {
logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_HEARTBEAT_ERR.getRetCode(), StatusCode.EVENTMESH_HEARTBEAT_ERR.getErrMsg(), e);
ServiceUtils.sendRespAndDone(StatusCode.EVENTMESH_HEARTBEAT_ERR, e.getMessage(), emitter);
}
});
}
use of org.apache.eventmesh.common.protocol.grpc.protos.Response in project incubator-eventmesh by apache.
the class ProducerService method publish.
public void publish(SimpleMessage request, StreamObserver<Response> responseObserver) {
cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", "AsyncPublish", EventMeshConstants.PROTOCOL_GRPC, request.getHeader().getIp(), eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp);
EventEmitter<Response> emitter = new EventEmitter<>(responseObserver);
threadPoolExecutor.submit(() -> {
SendAsyncMessageProcessor sendAsyncMessageProcessor = new SendAsyncMessageProcessor(eventMeshGrpcServer);
try {
sendAsyncMessageProcessor.process(request, emitter);
} catch (Exception e) {
logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getRetCode(), StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getErrMsg(), e);
ServiceUtils.sendRespAndDone(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, e.getMessage(), emitter);
}
});
}
use of org.apache.eventmesh.common.protocol.grpc.protos.Response in project incubator-eventmesh by apache.
the class ProducerService method batchPublish.
public void batchPublish(BatchMessage request, StreamObserver<Response> responseObserver) {
cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", "BatchPublish", EventMeshConstants.PROTOCOL_GRPC, request.getHeader().getIp(), eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp);
EventEmitter<Response> emitter = new EventEmitter<>(responseObserver);
threadPoolExecutor.submit(() -> {
BatchPublishMessageProcessor batchPublishMessageProcessor = new BatchPublishMessageProcessor(eventMeshGrpcServer);
try {
batchPublishMessageProcessor.process(request, emitter);
} catch (Exception e) {
logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_BATCH_PUBLISH_ERR.getRetCode(), StatusCode.EVENTMESH_BATCH_PUBLISH_ERR.getErrMsg(), e);
ServiceUtils.sendRespAndDone(StatusCode.EVENTMESH_BATCH_PUBLISH_ERR, e.getMessage(), emitter);
}
});
}
use of org.apache.eventmesh.common.protocol.grpc.protos.Response in project incubator-eventmesh by apache.
the class ServiceUtils method sendRespAndDone.
public static void sendRespAndDone(StatusCode code, EventEmitter<Response> emitter) {
Response response = Response.newBuilder().setRespCode(code.getRetCode()).setRespMsg(code.getErrMsg()).setRespTime(String.valueOf(System.currentTimeMillis())).build();
emitter.onNext(response);
emitter.onCompleted();
}
use of org.apache.eventmesh.common.protocol.grpc.protos.Response in project incubator-eventmesh by apache.
the class ServiceUtils method sendRespAndDone.
public static void sendRespAndDone(StatusCode code, String message, EventEmitter<Response> emitter) {
Response response = Response.newBuilder().setRespCode(code.getRetCode()).setRespMsg(code.getErrMsg() + " " + message).setRespTime(String.valueOf(System.currentTimeMillis())).build();
emitter.onNext(response);
emitter.onCompleted();
}
Aggregations