use of io.seata.core.protocol.HeartbeatMessage in project seata by seata.
the class AbstractNettyRemotingServer method sendAsyncResponse.
@Override
public void sendAsyncResponse(RpcMessage rpcMessage, Channel channel, Object msg) {
Channel clientChannel = channel;
if (!(msg instanceof HeartbeatMessage)) {
clientChannel = ChannelManager.getSameClientChannel(channel);
}
if (clientChannel != null) {
RpcMessage rpcMsg = buildResponseMessage(rpcMessage, msg, msg instanceof HeartbeatMessage ? ProtocolConstants.MSGTYPE_HEARTBEAT_RESPONSE : ProtocolConstants.MSGTYPE_RESPONSE);
super.sendAsync(clientChannel, rpcMsg);
} else {
throw new RuntimeException("channel is error.");
}
}
use of io.seata.core.protocol.HeartbeatMessage in project seata by seata.
the class HeartbeatMessageConvertorTest method test.
@Test
public void test() {
HeartbeatMessage heartbeatMessage = HeartbeatMessage.PING;
HeartbeatMessageConvertor convertor = new HeartbeatMessageConvertor();
HeartbeatMessageProto proto = convertor.convert2Proto(heartbeatMessage);
HeartbeatMessage real = convertor.convert2Model(proto);
assertThat(real).isEqualTo(heartbeatMessage);
}
use of io.seata.core.protocol.HeartbeatMessage in project seata by seata.
the class AbstractNettyRemotingClient method sendAsyncRequest.
@Override
public void sendAsyncRequest(Channel channel, Object msg) {
if (channel == null) {
LOGGER.warn("sendAsyncRequest nothing, caused by null channel.");
return;
}
RpcMessage rpcMessage = buildRequestMessage(msg, msg instanceof HeartbeatMessage ? ProtocolConstants.MSGTYPE_HEARTBEAT_REQUEST : ProtocolConstants.MSGTYPE_RESQUEST_ONEWAY);
if (rpcMessage.getBody() instanceof MergeMessage) {
mergeMsgMap.put(rpcMessage.getId(), (MergeMessage) rpcMessage.getBody());
}
super.sendAsync(channel, rpcMessage);
}
Aggregations