/** * Return true if there is a {@link ShutdownSignalException} in the cause tree and its * reason is "COMMAND_INVALID" and the operation being performed was exchangeDeclare. * For example attempting to declare an exchange that is not supported by the broker or * its plugins. * @param e the exception. * @return true if the exception was due to exchange declaration failed. * @since 1.6 */ public static boolean isExchangeDeclarationFailure(Exception e) { Throwable cause = e; ShutdownSignalException sig = null; while (cause != null && sig == null) { if (cause instanceof ShutdownSignalException) { sig = (ShutdownSignalException) cause; } cause = cause.getCause(); } if (sig == null) { return false; } else { Method shutdownReason = sig.getReason(); return shutdownReason instanceof AMQP.Connection.Close && AMQP.COMMAND_INVALID == ((AMQP.Connection.Close) shutdownReason).getReplyCode() && ((AMQP.Connection.Close) shutdownReason).getClassId() == EXCHANGE_CLASS_ID_40 && ((AMQP.Connection.Close) shutdownReason).getMethodId() == DECLARE_METHOD_ID_10; } }
/** * Return true if there is a {@link ShutdownSignalException} in the cause tree and its * reason is "COMMAND_INVALID" and the operation being performed was exchangeDeclare. * For example attempting to declare an exchange that is not supported by the broker or * its plugins. * @param e the exception. * @return true if the exception was due to exchange declaration failed. * @since 1.6 */ public static boolean isExchangeDeclarationFailure(Exception e) { Throwable cause = e; ShutdownSignalException sig = null; while (cause != null && sig == null) { if (cause instanceof ShutdownSignalException) { sig = (ShutdownSignalException) cause; } cause = cause.getCause(); } if (sig == null) { return false; } else { Method shutdownReason = sig.getReason(); return shutdownReason instanceof AMQP.Connection.Close && AMQP.COMMAND_INVALID == ((AMQP.Connection.Close) shutdownReason).getReplyCode() && ((AMQP.Connection.Close) shutdownReason).getClassId() == EXCHANGE_CLASS_ID_40 && ((AMQP.Connection.Close) shutdownReason).getMethodId() == DECLARE_METHOD_ID_10; } }