Talk about RemotingException of rocketmq

  mq

Order

This article mainly studies rocketmq’s RemotingException.

RemotingException

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

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);
    }
}
  • Inherited from checked exception, with RemotingCommandException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, RemotingToOmuCliqueException below.

RemotingCommandException

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

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);
    }
}
  • Exceptions that may be thrown when RemotingCommand decodes decodeCommandCustomHeader

RemotingConnectException

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

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 throws a RemotingConnectException when there is a problem with the channel

RemotingSendRequestException

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

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 throws a RemotingSendRequestException when sending a request fails.

RemotingTimeoutException

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

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);
    }
}
  • When NettyRemotingClient sends a request, if the RemotingCommand returned is null, but the sending request is successful, RemotingTimeoutException is thrown.

RemotingTooMuchRequestException

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

public class RemotingTooMuchRequestException extends RemotingException {
    private static final long serialVersionUID = 4326919581254519654L;

    public RemotingTooMuchRequestException(String message) {
        super(message);
    }
}
  • NettyRemotingAbstract executing the request, flow control shall be performed. If the semaphore cannot be obtained, whether it is timeout shall be distinguished. If the semaphore cannot be obtained without timeout, it means RemotingToOmuCliqueException.

Summary

The exception of rocketmq’s remoting module uses checked exception, which defines the root exception RemotingException. The following exceptions are RemotingCommandException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, RemotingToOmuCliqueException.

doc