Class ErrorMessagePublisher

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

public class ErrorMessagePublisher extends Object implements org.springframework.beans.factory.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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.apache.commons.logging.Log
     
    protected final MessagingTemplate
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Throwable
    determinePayload(Throwable throwable, org.springframework.core.AttributeAccessor context)
    Build a Throwable payload for future ErrorMessage.
    org.springframework.messaging.MessageChannel
     
    protected org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel>
     
     
     
    protected Throwable
    payloadWhenNull(org.springframework.core.AttributeAccessor context)
    Build a Throwable payload based on the provided context for future ErrorMessage when there is original Throwable.
    void
    publish(Throwable throwable, org.springframework.core.AttributeAccessor context)
    Publish an error message for the supplied throwable and context.
    void
    publish(org.springframework.messaging.Message<?> failedMessage, Throwable throwable)
    Publish an error message for the supplied message and throwable.
    void
    publish(org.springframework.messaging.Message<?> inputMessage, org.springframework.messaging.Message<?> failedMessage, Throwable throwable)
    Publish an error message for the supplied message and throwable.
    void
    publish(org.springframework.messaging.Message<?> inputMessage, org.springframework.messaging.MessagingException exception)
    Publish an error message for the supplied exception.
    void
    publish(org.springframework.messaging.MessagingException exception)
    Publish an error message for the supplied exception.
    void
    setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
     
    final void
    setChannel(org.springframework.messaging.MessageChannel channel)
     
    void
    setChannelName(String channelName)
     
    final void
    setChannelResolver(org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel> channelResolver)
     
    final void
     
    final void
    setSendTimeout(long sendTimeout)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      protected final org.apache.commons.logging.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(org.springframework.messaging.MessageChannel channel)
    • setChannelName

      public void setChannelName(String channelName)
    • getErrorMessageStrategy

      public ErrorMessageStrategy getErrorMessageStrategy()
    • getChannel

      public org.springframework.messaging.MessageChannel getChannel()
    • setSendTimeout

      public final void setSendTimeout(long sendTimeout)
    • setChannelResolver

      public final void setChannelResolver(org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel> channelResolver)
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
    • getMessagingTemplate

      protected MessagingTemplate getMessagingTemplate()
    • getChannelResolver

      @Nullable protected org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel> getChannelResolver()
    • publish

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

      public void publish(org.springframework.messaging.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(org.springframework.messaging.Message<?> inputMessage, org.springframework.messaging.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 org.springframework.messaging.Message<?> inputMessage, org.springframework.messaging.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, org.springframework.core.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, org.springframework.core.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(org.springframework.core.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: