Search in sources :

Example 1 with HeartbeatMessage

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.");
    }
}
Also used : HeartbeatMessage(io.seata.core.protocol.HeartbeatMessage) Channel(io.netty.channel.Channel) RpcMessage(io.seata.core.protocol.RpcMessage)

Example 2 with HeartbeatMessage

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);
}
Also used : HeartbeatMessageProto(io.seata.serializer.protobuf.generated.HeartbeatMessageProto) HeartbeatMessage(io.seata.core.protocol.HeartbeatMessage) Test(org.junit.jupiter.api.Test)

Example 3 with 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);
}
Also used : HeartbeatMessage(io.seata.core.protocol.HeartbeatMessage) RpcMessage(io.seata.core.protocol.RpcMessage) MergeMessage(io.seata.core.protocol.MergeMessage)

Aggregations

HeartbeatMessage (io.seata.core.protocol.HeartbeatMessage)3 RpcMessage (io.seata.core.protocol.RpcMessage)2 Channel (io.netty.channel.Channel)1 MergeMessage (io.seata.core.protocol.MergeMessage)1 HeartbeatMessageProto (io.seata.serializer.protobuf.generated.HeartbeatMessageProto)1 Test (org.junit.jupiter.api.Test)1