/** * Publish an error message for the supplied throwable and context. * The {@link #errorMessageStrategy} is used to build a {@link ErrorMessage} * to publish. * @param throwable the throwable. May be null. * @param context the context for {@link ErrorMessage} properties. */ public void publish(Throwable throwable, AttributeAccessor context) { populateChannel(); Throwable payload = determinePayload(throwable, context); ErrorMessage errorMessage = this.errorMessageStrategy.buildErrorMessage(payload, context); if (this.logger.isDebugEnabled() && payload instanceof MessagingException) { MessagingException exception = (MessagingException) errorMessage.getPayload(); this.logger.debug("Sending ErrorMessage: failedMessage: " + exception.getFailedMessage(), exception); } this.messagingTemplate.send(errorMessage); }
/** * Publish an error message for the supplied message and throwable. If the throwable * is already a {@link MessagingException} containing the message in its * {@code failedMessage} property, use {@link #publish(MessagingException)} instead. * @param failedMessage the message. * @param throwable the throwable. */ public void publish(Message<?> failedMessage, Throwable throwable) { publish(null, failedMessage, throwable); }
public MessageChannel getChannel() { populateChannel(); return this.channel; }
/** * Build a {@code Throwable payload} for future {@link ErrorMessage}. * @param throwable the error to determine an {@link ErrorMessage} payload. Can be null. * @param context the context for error. * @return the throwable for the {@link ErrorMessage} payload * @see ErrorMessageUtils */ protected Throwable determinePayload(Throwable throwable, AttributeAccessor context) { Throwable lastThrowable = throwable; if (lastThrowable == null) { lastThrowable = payloadWhenNull(context); } else if (!(lastThrowable instanceof MessagingException)) { Message<?> message = (Message<?>) context.getAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY); lastThrowable = message == null ? new MessagingException(lastThrowable.getMessage(), lastThrowable) : new MessagingException(message, lastThrowable.getMessage(), lastThrowable); } return lastThrowable; }
public MessageChannel getChannel() { populateChannel(); return this.channel; }
/** * Build a {@code Throwable payload} for future {@link ErrorMessage}. * @param throwable the error to determine an {@link ErrorMessage} payload. Can be null. * @param context the context for error. * @return the throwable for the {@link ErrorMessage} payload * @see ErrorMessageUtils */ protected Throwable determinePayload(Throwable throwable, AttributeAccessor context) { Throwable lastThrowable = throwable; if (lastThrowable == null) { lastThrowable = payloadWhenNull(context); } else if (!(lastThrowable instanceof MessagingException)) { Message<?> message = (Message<?>) context.getAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY); lastThrowable = message == null ? new MessagingException(lastThrowable.getMessage(), lastThrowable) : new MessagingException(message, lastThrowable.getMessage(), lastThrowable); } return lastThrowable; }
/** * Publish an error message for the supplied message and throwable. If the throwable * is already a {@link MessagingException} containing the message in its * {@code failedMessage} property, use {@link #publish(MessagingException)} instead. * @param inputMessage the message that started the subflow. * @param failedMessage the message. * @param throwable the throwable. */ public void publish(@Nullable Message<?> inputMessage, Message<?> failedMessage, Throwable throwable) { publish(throwable, ErrorMessageUtils.getAttributeAccessor(inputMessage, failedMessage)); }
/** * Publish an error message for the supplied throwable and context. * The {@link #errorMessageStrategy} is used to build a {@link ErrorMessage} * to publish. * @param throwable the throwable. May be null. * @param context the context for {@link ErrorMessage} properties. */ public void publish(Throwable throwable, AttributeAccessor context) { populateChannel(); Throwable payload = determinePayload(throwable, context); ErrorMessage errorMessage = this.errorMessageStrategy.buildErrorMessage(payload, context); if (this.logger.isDebugEnabled() && payload instanceof MessagingException) { MessagingException exception = (MessagingException) errorMessage.getPayload(); this.logger.debug("Sending ErrorMessage: failedMessage: " + exception.getFailedMessage(), exception); } this.messagingTemplate.send(errorMessage); }
/** * Publish an error message for the supplied exception. * @param exception the exception. */ public void publish(MessagingException exception) { publish(null, exception.getFailedMessage(), exception); }
/** * Publish an error message for the supplied exception. * @param inputMessage the message that started the subflow. * @param exception the exception. */ public void publish(Message<?> inputMessage, MessagingException exception) { publish(inputMessage, exception.getFailedMessage(), exception); }
/** * Publish an error message for the supplied message and throwable. If the throwable * is already a {@link MessagingException} containing the message in its * {@code failedMessage} property, use {@link #publish(MessagingException)} instead. * @param failedMessage the message. * @param throwable the throwable. */ public void publish(Message<?> failedMessage, Throwable throwable) { publish(null, failedMessage, throwable); }
/** * Publish an error message for the supplied exception. * @param inputMessage the message that started the subflow. * @param exception the exception. */ public void publish(Message<?> inputMessage, MessagingException exception) { publish(inputMessage, exception.getFailedMessage(), exception); }
/** * Publish an error message for the supplied exception. * @param exception the exception. */ public void publish(MessagingException exception) { publish(null, exception.getFailedMessage(), exception); }
/** * Publish an error message for the supplied message and throwable. If the throwable * is already a {@link MessagingException} containing the message in its * {@code failedMessage} property, use {@link #publish(MessagingException)} instead. * @param inputMessage the message that started the subflow. * @param failedMessage the message. * @param throwable the throwable. */ public void publish(@Nullable Message<?> inputMessage, Message<?> failedMessage, Throwable throwable) { publish(throwable, ErrorMessageUtils.getAttributeAccessor(inputMessage, failedMessage)); }