use of org.apache.eventmesh.client.tcp.common.RequestContext in project incubator-eventmesh by apache.
the class AbstractEventMeshTCPSubHandler method channelRead0.
@Override
protected void channelRead0(ChannelHandlerContext ctx, Package msg) throws Exception {
Preconditions.checkNotNull(msg, "TCP package cannot be null");
Preconditions.checkNotNull(msg.getHeader(), "TCP package header cannot be null");
Command cmd = msg.getHeader().getCmd();
log.info("|receive|type={}|msg={}", cmd, msg);
switch(cmd) {
case REQUEST_TO_CLIENT:
callback(getProtocolMessage(msg), ctx);
response(MessageUtils.requestToClientAck(msg));
break;
case ASYNC_MESSAGE_TO_CLIENT:
callback(getProtocolMessage(msg), ctx);
response(MessageUtils.asyncMessageAck(msg));
break;
case BROADCAST_MESSAGE_TO_CLIENT:
callback(getProtocolMessage(msg), ctx);
response(MessageUtils.broadcastMessageAck(msg));
break;
case SERVER_GOODBYE_REQUEST:
// TODO
break;
default:
log.error("msg ignored|{}|{}", cmd, msg);
}
RequestContext context = contexts.get(RequestContext.key(msg));
if (context != null) {
contexts.remove(context.getKey());
context.finish(msg);
} else {
log.error("msg ignored,context not found.|{}|{}", cmd, msg);
}
}
use of org.apache.eventmesh.client.tcp.common.RequestContext in project incubator-eventmesh by apache.
the class AbstractEventMeshTCPPubHandler method channelRead0.
@Override
protected void channelRead0(ChannelHandlerContext ctx, Package msg) {
log.info("SimplePubClientImpl|receive|msg={}", msg);
Preconditions.checkNotNull(msg.getHeader(), "Tcp package header cannot be null");
Command cmd = msg.getHeader().getCmd();
switch(cmd) {
case RESPONSE_TO_CLIENT:
callback(getMessage(msg), ctx);
sendResponse(MessageUtils.responseToClientAck(msg));
break;
case SERVER_GOODBYE_REQUEST:
// TODO
break;
default:
break;
}
RequestContext context = contexts.get(RequestContext.key(msg));
if (context != null) {
contexts.remove(context.getKey());
context.finish(msg);
}
}
Aggregations