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 java.lang.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 org.apache.commons.logging.Logloggerprotected MessagingTemplatemessagingTemplate -
Constructor Summary
Constructors Constructor Description ErrorMessagePublisher() -
Method Summary
Modifier and Type Method Description protected java.lang.ThrowabledeterminePayload(java.lang.Throwable throwable, org.springframework.core.AttributeAccessor context)Build aThrowable payloadfor futureErrorMessage.org.springframework.messaging.MessageChannelgetChannel()protected org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel>getChannelResolver()ErrorMessageStrategygetErrorMessageStrategy()protected MessagingTemplategetMessagingTemplate()protected java.lang.ThrowablepayloadWhenNull(org.springframework.core.AttributeAccessor context)Build aThrowable payloadbased on the provided context for futureErrorMessagewhen there is originalThrowable.voidpublish(java.lang.Throwable throwable, org.springframework.core.AttributeAccessor context)Publish an error message for the supplied throwable and context.voidpublish(org.springframework.messaging.Message<?> failedMessage, java.lang.Throwable throwable)Publish an error message for the supplied message and throwable.voidpublish(org.springframework.messaging.Message<?> inputMessage, org.springframework.messaging.Message<?> failedMessage, java.lang.Throwable throwable)Publish an error message for the supplied message and throwable.voidpublish(org.springframework.messaging.Message<?> inputMessage, org.springframework.messaging.MessagingException exception)Publish an error message for the supplied exception.voidpublish(org.springframework.messaging.MessagingException exception)Publish an error message for the supplied exception.voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)voidsetChannel(org.springframework.messaging.MessageChannel channel)voidsetChannelName(java.lang.String channelName)voidsetChannelResolver(org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel> channelResolver)voidsetErrorMessageStrategy(ErrorMessageStrategy errorMessageStrategy)voidsetSendTimeout(long sendTimeout)
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger -
messagingTemplate
-
-
Constructor Details
-
ErrorMessagePublisher
public ErrorMessagePublisher()
-
-
Method Details
-
setErrorMessageStrategy
-
setChannel
public final void setChannel(org.springframework.messaging.MessageChannel channel) -
setChannelName
public void setChannelName(java.lang.String channelName) -
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:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware
-
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, java.lang.Throwable throwable)Publish an error message for the supplied message and throwable. If the throwable is already aMessagingExceptioncontaining the message in itsfailedMessageproperty, usepublish(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, java.lang.Throwable throwable)Publish an error message for the supplied message and throwable. If the throwable is already aMessagingExceptioncontaining the message in itsfailedMessageproperty, usepublish(MessagingException)instead.- Parameters:
inputMessage- the message that started the subflow.failedMessage- the message.throwable- the throwable.
-
publish
public void publish(java.lang.Throwable throwable, org.springframework.core.AttributeAccessor context)Publish an error message for the supplied throwable and context. TheerrorMessageStrategyis used to build aErrorMessageto publish.- Parameters:
throwable- the throwable. May be null.context- the context forErrorMessageproperties.
-
determinePayload
protected java.lang.Throwable determinePayload(java.lang.Throwable throwable, org.springframework.core.AttributeAccessor context)Build aThrowable payloadfor futureErrorMessage.- Parameters:
throwable- the error to determine anErrorMessagepayload. Can be null.context- the context for error.- Returns:
- the throwable for the
ErrorMessagepayload - See Also:
ErrorMessageUtils
-
payloadWhenNull
protected java.lang.Throwable payloadWhenNull(org.springframework.core.AttributeAccessor context)Build aThrowable payloadbased on the provided context for futureErrorMessagewhen there is originalThrowable.- Parameters:
context- theAttributeAccessorto use for exception properties.- Returns:
- the
Throwablefor anErrorMessagepayload. - See Also:
ErrorMessageUtils
-