本文整理汇总了Java中com.alibaba.dubbo.remoting.exchange.Response.setEvent方法的典型用法代码示例。如果您正苦于以下问题:Java Response.setEvent方法的具体用法?Java Response.setEvent怎么用?Java Response.setEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.remoting.exchange.Response
的用法示例。
在下文中一共展示了Response.setEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: received
import com.alibaba.dubbo.remoting.exchange.Response; //导入方法依赖的package包/类
public void received(Channel channel, Object message) throws RemotingException {
setReadTimestamp(channel);
if (isHeartbeatRequest(message)) {
Request req = (Request) message;
if (req.isTwoWay()) {
Response res = new Response(req.getId(), req.getVersion());
res.setEvent(Response.HEARTBEAT_EVENT);
channel.send(res);
if (logger.isInfoEnabled()) {
int heartbeat = channel.getUrl().getParameter(Constants.HEARTBEAT_KEY, 0);
if(logger.isDebugEnabled()) {
logger.debug("Received heartbeat from remote channel " + channel.getRemoteAddress()
+ ", cause: The channel has no data-transmission exceeds a heartbeat period"
+ (heartbeat > 0 ? ": " + heartbeat + "ms" : ""));
}
}
}
return;
}
if (isHeartbeatResponse(message)) {
if (logger.isDebugEnabled()) {
logger.debug(
new StringBuilder(32)
.append("Receive heartbeat response in thread ")
.append(Thread.currentThread().getName())
.toString());
}
return;
}
handler.received(channel, message);
}
示例2: received
import com.alibaba.dubbo.remoting.exchange.Response; //导入方法依赖的package包/类
@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 );
}
}