Search in sources :

Example 31 with Response

use of com.alibaba.dubbo.remoting.exchange.Response in project dubbo by alibaba.

the class HeartBeatExchangeHandler method received.

@Override
public void received(Channel channel, Object message) throws RemotingException {
    if (message instanceof Request) {
        Request req = (Request) message;
        if (req.isHeartbeat()) {
            heartBeatCounter.incrementAndGet();
            channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis());
            Response res = new Response(req.getId(), req.getVersion());
            res.setEvent(req.getData() == null ? null : req.getData().toString());
            channel.send(res);
        }
    } else {
        super.received(channel, message);
    }
}
Also used : Response(com.alibaba.dubbo.remoting.exchange.Response) Request(com.alibaba.dubbo.remoting.exchange.Request)

Aggregations

Response (com.alibaba.dubbo.remoting.exchange.Response)31 Request (com.alibaba.dubbo.remoting.exchange.Request)18 Test (org.junit.Test)17 Channel (com.alibaba.dubbo.remoting.Channel)10 ChannelBuffer (com.alibaba.dubbo.remoting.buffer.ChannelBuffer)8 RemotingException (com.alibaba.dubbo.remoting.RemotingException)6 Serialization (com.alibaba.dubbo.common.serialize.Serialization)5 ExchangeChannel (com.alibaba.dubbo.remoting.exchange.ExchangeChannel)5 RpcResult (com.alibaba.dubbo.rpc.RpcResult)5 TMessage (org.apache.thrift.protocol.TMessage)5 URL (com.alibaba.dubbo.common.URL)4 Demo (com.alibaba.dubbo.rpc.gen.thrift.Demo)4 IOException (java.io.IOException)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)4 TIOStreamTransport (org.apache.thrift.transport.TIOStreamTransport)4 HeaderExchangeHandler (com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler)3 TApplicationException (org.apache.thrift.TApplicationException)3 ObjectInput (com.alibaba.dubbo.common.serialize.ObjectInput)2 ObjectOutput (com.alibaba.dubbo.common.serialize.ObjectOutput)2