Class ErrorMessagePublisher

java.lang.Object
org.springframework.integration.core.ErrorMessagePublisher
All Implemented Interfaces:
Aware, BeanFactoryAware
Direct Known Subclasses:
ErrorMessageSendingRecoverer, KafkaErrorSendingMessageRecoverer, MessagePublishingErrorHandler

public class ErrorMessagePublisher extends Object implements BeanFactoryAware
The component which can be used as general purpose of errors publishing. Can be called or extended in any error handling or retry scenarios.

An ErrorMessageStrategy can be used to provide customization for the target ErrorMessage based on the AttributeAccessor (or the message and/or throwable when using the other publish() methods).

Since:
4.3.10
Author:
Artem Bilan, Gary Russell
  • Field Details

    • logger

      protected final Log logger
    • messagingTemplate

      protected final MessagingTemplate messagingTemplate
  • Constructor Details

    • ErrorMessagePublisher

      public ErrorMessagePublisher()
  • Method Details

    • setErrorMessageStrategy

      public final void setErrorMessageStrategy(ErrorMessageStrategy errorMessageStrategy)
    • setChannel

      public final void setChannel(MessageChannel channel)
    • setChannelName

      public void setChannelName(String channelName)
    • getErrorMessageStrategy

      public ErrorMessageStrategy getErrorMessageStrategy()
    • getChannel

      public MessageChannel getChannel()
    • setSendTimeout

      public final void setSendTimeout(long sendTimeout)
    • setChannelResolver

      public final void setChannelResolver(DestinationResolver<MessageChannel> channelResolver)
    • setBeanFactory

      public void setBeanFactory(BeanFactory beanFactory)
      Specified by:
      setBeanFactory in interface BeanFactoryAware
    • getMessagingTemplate

      protected MessagingTemplate getMessagingTemplate()
    • getChannelResolver

      @Nullable protected DestinationResolver<MessageChannel> getChannelResolver()
    • publish

      public void publish(MessagingException exception)
      Publish an error message for the supplied exception.
      Parameters:
      exception - the exception.
    • publish

      public void publish(Message<?> failedMessage, Throwable throwable)
      Publish an error message for the supplied message and throwable. If the throwable is already a MessagingException containing the message in its failedMessage property, use publish(MessagingException) instead.
      Parameters:
      failedMessage - the message.
      throwable - the throwable.
    • publish

      public void publish(Message<?> inputMessage, MessagingException exception)
      Publish an error message for the supplied exception.
      Parameters:
      inputMessage - the message that started the subflow.
      exception - the exception.
    • publish

      public void publish(@Nullable Message<?> inputMessage, Message<?> failedMessage, Throwable throwable)
      Publish an error message for the supplied message and throwable. If the throwable is already a MessagingException containing the message in its failedMessage property, use publish(MessagingException) instead.
      Parameters:
      inputMessage - the message that started the subflow.
      failedMessage - the message.
      throwable - the throwable.
    • publish

      public void publish(Throwable throwable, AttributeAccessor context)
      Publish an error message for the supplied throwable and context. The errorMessageStrategy is used to build a ErrorMessage to publish.
      Parameters:
      throwable - the throwable. May be null.
      context - the context for ErrorMessage properties.
    • determinePayload

      protected Throwable determinePayload(Throwable throwable, AttributeAccessor context)
      Build a Throwable payload for future ErrorMessage.
      Parameters:
      throwable - the error to determine an ErrorMessage payload. Can be null.
      context - the context for error.
      Returns:
      the throwable for the ErrorMessage payload
      See Also:
    • payloadWhenNull

      protected Throwable payloadWhenNull(AttributeAccessor context)
      Build a Throwable payload based on the provided context for future ErrorMessage when there is original Throwable.
      Parameters:
      context - the AttributeAccessor to use for exception properties.
      Returns:
      the Throwable for an ErrorMessage payload.
      See Also: