private static boolean isValidClose(final Close close) { boolean result=false; if(close.getReplyCode()==406 && close.getMethodId()==10) { final PreconditionFailure failure=PreconditionFailure.fromString(close.getReplyText()); if(failure!=null) { final String argument = failure.argument(); result=!"type".equals(argument) && !"internal".equals(argument); if(!result) { LOGGER.error("Cannot recover from {}",failure); } } } return result; }
Method shutdownReason = shutdown.get().getReason(); assertThat(shutdownReason, instanceOf(AMQP.Channel.Close.class)); assertThat(((AMQP.Channel.Close) shutdownReason).getReplyCode(), equalTo(AMQP.NOT_FOUND));
/** * Return true if there is a {@link ShutdownSignalException} in the cause tree and its * reason is "PRECONDITION_FAILED" and the operation being performed was queueDeclare. * This can happen if a queue has mismatched properties (auto-delete etc) or arguments * (x-message-ttl etc). * @param e the exception. * @return true if the exception was due to queue declaration precondition failed. * @since 1.6 */ public static boolean isMismatchedQueueArgs(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.Channel.Close && AMQP.PRECONDITION_FAILED == ((AMQP.Channel.Close) shutdownReason).getReplyCode() && ((AMQP.Channel.Close) shutdownReason).getClassId() == QUEUE_CLASS_ID_50 && ((AMQP.Channel.Close) shutdownReason).getMethodId() == DECLARE_METHOD_ID_10; } }
/** * Return true if there is a {@link ShutdownSignalException} in the cause tree and its * reason is "PRECONDITION_FAILED" and the operation being performed was queueDeclare. * This can happen if a queue has mismatched properties (auto-delete etc) or arguments * (x-message-ttl etc). * @param e the exception. * @return true if the exception was due to queue declaration precondition failed. * @since 1.6 */ public static boolean isMismatchedQueueArgs(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.Channel.Close && AMQP.PRECONDITION_FAILED == ((AMQP.Channel.Close) shutdownReason).getReplyCode() && ((AMQP.Channel.Close) shutdownReason).getClassId() == QUEUE_CLASS_ID_50 && ((AMQP.Channel.Close) shutdownReason).getMethodId() == DECLARE_METHOD_ID_10; } }
/** * Return true if the {@link ShutdownSignalException} reason is AMQP.Channel.Close * and the operation that failed was basicConsumer and the failure text contains * "exclusive". * @param sig the exception. * @return true if the declaration failed because of an exclusive queue. */ public static boolean isExclusiveUseChannelClose(ShutdownSignalException sig) { Method shutdownReason = sig.getReason(); return shutdownReason instanceof AMQP.Channel.Close // NOSONAR boolean complexity && AMQP.ACCESS_REFUSED == ((AMQP.Channel.Close) shutdownReason).getReplyCode() && ((AMQP.Channel.Close) shutdownReason).getClassId() == BASIC_CLASS_ID_60 && ((AMQP.Channel.Close) shutdownReason).getMethodId() == CONSUME_METHOD_ID_20 && ((AMQP.Channel.Close) shutdownReason).getReplyText().contains("exclusive"); }
/** * Return true if the {@link ShutdownSignalException} reason is AMQP.Channel.Close * and the operation that failed was exchangeDeclare or queueDeclare. * @param sig the exception. * @return true if the failure meets the conditions. */ public static boolean isPassiveDeclarationChannelClose(ShutdownSignalException sig) { Method shutdownReason = sig.getReason(); return shutdownReason instanceof AMQP.Channel.Close // NOSONAR boolean complexity && AMQP.NOT_FOUND == ((AMQP.Channel.Close) shutdownReason).getReplyCode() && ((((AMQP.Channel.Close) shutdownReason).getClassId() == EXCHANGE_CLASS_ID_40 || ((AMQP.Channel.Close) shutdownReason).getClassId() == QUEUE_CLASS_ID_50) && ((AMQP.Channel.Close) shutdownReason).getMethodId() == DECLARE_METHOD_ID_10); }
/** * Return true if the {@link ShutdownSignalException} reason is AMQP.Channel.Close * and the operation that failed was basicConsumer and the failure text contains * "exclusive". * @param sig the exception. * @return true if the declaration failed because of an exclusive queue. */ public static boolean isExclusiveUseChannelClose(ShutdownSignalException sig) { Method shutdownReason = sig.getReason(); return shutdownReason instanceof AMQP.Channel.Close // NOSONAR boolean complexity && AMQP.ACCESS_REFUSED == ((AMQP.Channel.Close) shutdownReason).getReplyCode() && ((AMQP.Channel.Close) shutdownReason).getClassId() == BASIC_CLASS_ID_60 && ((AMQP.Channel.Close) shutdownReason).getMethodId() == CONSUME_METHOD_ID_20 && ((AMQP.Channel.Close) shutdownReason).getReplyText().contains("exclusive"); }
/** * Return true if the {@link ShutdownSignalException} reason is AMQP.Channel.Close and * the reply code was AMQP.REPLY_SUCCESS (200) and the text equals "OK". * @param sig the exception. * @return true for a normal channel close. */ public static boolean isNormalChannelClose(ShutdownSignalException sig) { Method shutdownReason = sig.getReason(); return isNormalShutdown(sig) || (shutdownReason instanceof AMQP.Channel.Close && AMQP.REPLY_SUCCESS == ((AMQP.Channel.Close) shutdownReason).getReplyCode() && "OK".equals(((AMQP.Channel.Close) shutdownReason).getReplyText())); }
/** * Return true if the {@link ShutdownSignalException} reason is AMQP.Channel.Close * and the operation that failed was exchangeDeclare or queueDeclare. * @param sig the exception. * @return true if the failure meets the conditions. */ public static boolean isPassiveDeclarationChannelClose(ShutdownSignalException sig) { Method shutdownReason = sig.getReason(); return shutdownReason instanceof AMQP.Channel.Close // NOSONAR boolean complexity && AMQP.NOT_FOUND == ((AMQP.Channel.Close) shutdownReason).getReplyCode() && ((((AMQP.Channel.Close) shutdownReason).getClassId() == EXCHANGE_CLASS_ID_40 || ((AMQP.Channel.Close) shutdownReason).getClassId() == QUEUE_CLASS_ID_50) && ((AMQP.Channel.Close) shutdownReason).getMethodId() == DECLARE_METHOD_ID_10); }
private static boolean isValidClose(final Close close) { if(close.getReplyCode()==406 && close.getMethodId()==10) { final PreconditionFailure failure=PreconditionFailure.fromString(close.getReplyText()); if(failure!=null) { final String argument = failure.argument(); if(!"type".equals(argument) && !"internal".equals(argument)) { return true; } LOGGER.error("Cannot recover from {}",failure); } } return false; }
private static boolean isRetryable(ShutdownSignalException e) { if (e.isInitiatedByApplication()) return false; Method method = e.getReason(); if (method instanceof AMQP.Connection.Close) return isRetryable(((AMQP.Connection.Close) method).getReplyCode()); if (method instanceof AMQP.Channel.Close) return isRetryable(((AMQP.Channel.Close) method).getReplyCode()); return false; } }
/** * Return true if the {@link ShutdownSignalException} reason is AMQP.Channel.Close and * the reply code was AMQP.REPLY_SUCCESS (200) and the text equals "OK". * @param sig the exception. * @return true for a normal channel close. */ public static boolean isNormalChannelClose(ShutdownSignalException sig) { Method shutdownReason = sig.getReason(); return isNormalShutdown(sig) || (shutdownReason instanceof AMQP.Channel.Close && AMQP.REPLY_SUCCESS == ((AMQP.Channel.Close) shutdownReason).getReplyCode() && "OK".equals(((AMQP.Channel.Close) shutdownReason).getReplyText())); }
private static boolean isValidClose(final Close close) { if(close.getReplyCode()==406 && close.getMethodId()==10) { final PreconditionFailure failure=PreconditionFailure.fromString(close.getReplyText()); if(failure!=null) { final String argument = failure.argument(); if(!"type".equals(argument) && !"internal".equals(argument)) { return true; } LOGGER.error("Cannot recover from {}",failure); } } return false; }
private static boolean isRetryable(ShutdownSignalException e) { if (e.isInitiatedByApplication()) return false; Method method = e.getReason(); if (method instanceof AMQP.Connection.Close) return isRetryable(((AMQP.Connection.Close) method).getReplyCode()); if (method instanceof AMQP.Channel.Close) return isRetryable(((AMQP.Channel.Close) method).getReplyCode()); return false; } }