Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

修复 RpcChannel 中 netty 发送失败时未调用 callback 的问题 #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import org.slf4j.LoggerFactory;

import com.baidu.jprotobuf.pbrpc.data.RpcDataPackage;
import com.baidu.jprotobuf.pbrpc.transport.handler.ErrorCodes;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.util.Timeout;

/**
Expand Down Expand Up @@ -138,7 +140,11 @@ public void doTransport(Connection connection, RpcDataPackage rpcDataPackage,

LOG.debug("Do send request with service name '" + rpcDataPackage.serviceName() + "' method name '"
+ rpcDataPackage.methodName() + "' bound channel =>" + channel);
channel.writeAndFlush(state.getDataPackage());
channel.writeAndFlush(state.getDataPackage()).addListener((ChannelFutureListener) channelFuture -> {
if (!channelFuture.isSuccess() && channelFuture.cause() != null) {
state.handleFailure(ErrorCodes.ST_WRITE_FAILED, channelFuture.cause().getMessage());
}
});
}

long callMethodEnd = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class ErrorCodes {
/** read time out. */
public static final int ST_READ_TIMEOUT = 62;

/** 消息发送异常. */
public static final int ST_WRITE_FAILED = 4001;

/** onceTalkTimeout timeout message. */
public static final String MSG_READ_TIMEOUT =
"method request time out, please check 'onceTalkTimeout' property. current value is:";
Expand Down