前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >聊聊rocketmq的RemotingException

聊聊rocketmq的RemotingException

作者头像
code4it
发布2018-09-17 17:17:26
2.5K0
发布2018-09-17 17:17:26
举报
文章被收录于专栏:码匠的流水账

本文主要研究一下rocketmq的RemotingException

RemotingException

org/apache/rocketmq/remoting/exception/RemotingException.java

代码语言:javascript
复制
public class RemotingException extends Exception {
    private static final long serialVersionUID = -5690687334570505110L;

    public RemotingException(String message) {
        super(message);
    }

    public RemotingException(String message, Throwable cause) {
        super(message, cause);
    }
}
  • 继承自checked exception,底下有RemotingCommandException、RemotingConnectException、RemotingSendRequestException、RemotingTimeoutException、RemotingTooMuchRequestException

RemotingCommandException

org/apache/rocketmq/remoting/exception/RemotingCommandException.java

代码语言:javascript
复制
public class RemotingCommandException extends RemotingException {
    private static final long serialVersionUID = -6061365915274953096L;

    public RemotingCommandException(String message) {
        super(message, null);
    }

    public RemotingCommandException(String message, Throwable cause) {
        super(message, cause);
    }
}
  • RemotingCommand解码decodeCommandCustomHeader时可能抛出的异常

RemotingConnectException

org/apache/rocketmq/remoting/exception/RemotingConnectException.java

代码语言:javascript
复制
public class RemotingConnectException extends RemotingException {
    private static final long serialVersionUID = -5565366231695911316L;

    public RemotingConnectException(String addr) {
        this(addr, null);
    }

    public RemotingConnectException(String addr, Throwable cause) {
        super("connect to <" + addr + "> failed", cause);
    }
}
  • NettyRemotingClient在channel出现问题的时候会抛出RemotingConnectException

RemotingSendRequestException

org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java

代码语言:javascript
复制
public class RemotingSendRequestException extends RemotingException {
    private static final long serialVersionUID = 5391285827332471674L;

    public RemotingSendRequestException(String addr) {
        this(addr, null);
    }

    public RemotingSendRequestException(String addr, Throwable cause) {
        super("send request to <" + addr + "> failed", cause);
    }
}
  • NettyRemotingClient在发送请求失败的时候,会抛出RemotingSendRequestException

RemotingTimeoutException

org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java

代码语言:javascript
复制
public class RemotingTimeoutException extends RemotingException {

    private static final long serialVersionUID = 4106899185095245979L;

    public RemotingTimeoutException(String message) {
        super(message);
    }

    public RemotingTimeoutException(String addr, long timeoutMillis) {
        this(addr, timeoutMillis, null);
    }

    public RemotingTimeoutException(String addr, long timeoutMillis, Throwable cause) {
        super("wait response on the channel <" + addr + "> timeout, " + timeoutMillis + "(ms)", cause);
    }
}
  • NettyRemotingClient在发送请求时,如果返回回来的RemotingCommand为null,但是发送请求成功,则抛出RemotingTimeoutException

RemotingTooMuchRequestException

org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java

代码语言:javascript
复制
public class RemotingTooMuchRequestException extends RemotingException {
    private static final long serialVersionUID = 4326919581254519654L;

    public RemotingTooMuchRequestException(String message) {
        super(message);
    }
}
  • NettyRemotingAbstract在执行请求之前要进行流控,如果获取不到信号量,则区分是否是超时,如果是无timeout获取信号量也没获取到,则表示RemotingTooMuchRequestException

小结

rocketmq的remoting模块的异常采用的是checked exception,定义了根异常RemotingException,底下有几个异常分别为RemotingCommandException、RemotingConnectException、RemotingSendRequestException、RemotingTimeoutException、RemotingTooMuchRequestException。

doc

  • RemotingException
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2018-08-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 码匠的流水账 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • RemotingException
    • RemotingCommandException
      • RemotingConnectException
        • RemotingSendRequestException
          • RemotingTimeoutException
            • RemotingTooMuchRequestException
            • 小结
            • doc
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档