@Override public boolean isFatal(Throwable t) { if (t instanceof ListenerExecutionFailedException) { ListenerExecutionFailedException lefe = (ListenerExecutionFailedException) t; logger.error("Failed to process inbound message from queue " + lefe.getFailedMessage().getMessageProperties().getConsumerQueue() + "; failed message: " + lefe.getFailedMessage(), t); } return super.isFatal(t); }
@Override public boolean isFatal(Throwable t) { Throwable cause = t.getCause(); while (cause instanceof MessagingException && !(cause instanceof org.springframework.messaging.converter.MessageConversionException) && !(cause instanceof MethodArgumentResolutionException)) { cause = cause.getCause(); } if (t instanceof ListenerExecutionFailedException && isCauseFatal(cause)) { if (this.logger.isWarnEnabled()) { this.logger.warn( "Fatal message conversion error; message rejected; " + "it will be dropped or routed to a dead letter exchange, if so configured: " + ((ListenerExecutionFailedException) t).getFailedMessage()); } return true; } return false; }
@Override public boolean isFatal(Throwable t) { Throwable cause = t.getCause(); while (cause instanceof MessagingException && !(cause instanceof org.springframework.messaging.converter.MessageConversionException) && !(cause instanceof MethodArgumentResolutionException)) { cause = cause.getCause(); } if (t instanceof ListenerExecutionFailedException && isCauseFatal(cause)) { if (this.logger.isWarnEnabled()) { this.logger.warn( "Fatal message conversion error; message rejected; " + "it will be dropped or routed to a dead letter exchange, if so configured: " + ((ListenerExecutionFailedException) t).getFailedMessage()); } return true; } return false; }
@Override public void handleError(Throwable t) { log(t); if (!this.causeChainContainsARADRE(t) && this.exceptionStrategy.isFatal(t)) { if (this.discardFatalsWithXDeath && t instanceof ListenerExecutionFailedException) { Message failed = ((ListenerExecutionFailedException) t).getFailedMessage(); if (failed != null) { List<Map<String, ?>> xDeath = failed.getMessageProperties().getXDeathHeader(); if (xDeath != null && xDeath.size() > 0) { this.logger.error("x-death header detected on a message with a fatal exception; " + "perhaps requeued from a DLQ? - discarding: " + failed); throw new ImmediateAcknowledgeAmqpException("Fatal and x-death present"); } } } throw new AmqpRejectAndDontRequeueException("Error Handler converted exception to fatal", t); } }
@Override public void handleError(Throwable t) { log(t); if (!this.causeChainContainsARADRE(t) && this.exceptionStrategy.isFatal(t)) { if (this.discardFatalsWithXDeath && t instanceof ListenerExecutionFailedException) { Message failed = ((ListenerExecutionFailedException) t).getFailedMessage(); if (failed != null) { List<Map<String, ?>> xDeath = failed.getMessageProperties().getXDeathHeader(); if (xDeath != null && xDeath.size() > 0) { this.logger.error("x-death header detected on a message with a fatal exception; " + "perhaps requeued from a DLQ? - discarding: " + failed); throw new ImmediateAcknowledgeAmqpException("Fatal and x-death present"); } } } throw new AmqpRejectAndDontRequeueException("Error Handler converted exception to fatal", t); } }
ConditionalRejectingErrorHandler eh = new ConditionalRejectingErrorHandler(t -> { if (t instanceof ListenerExecutionFailedException) { failed.set(((ListenerExecutionFailedException) t).getFailedMessage());