public class IdempotentReceiverInterceptor extends AbstractHandleMessageAdvice
MethodInterceptor implementation for the
Idempotent Receiver
E.I. Pattern.
This MethodInterceptor works like a
MessageFilter if discardChannel
is provided or throwExceptionOnRejection is set to true.
However if those properties aren't provided, this interceptor will create an new Message
with a IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE header when the
requestMessage isn't accepted by MessageSelector.
The idempotent filtering logic depends on the provided MessageSelector.
This class is designed to be used only for the
MessageHandler.handleMessage(org.springframework.messaging.Message<?>),
method.
MetadataStoreSelector,
IdempotentReceiverAutoProxyCreatorInitializerEXPRESSION_PARSER, logger| Constructor and Description |
|---|
IdempotentReceiverInterceptor(MessageSelector messageSelector) |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
doInvoke(MethodInvocation invocation,
Message<?> message) |
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
void |
setDiscardChannel(MessageChannel discardChannel)
Specify a channel where rejected Messages should be sent.
|
void |
setDiscardChannelName(String discardChannelName)
Specify a channel name where rejected Messages should be sent.
|
void |
setThrowExceptionOnRejection(boolean throwExceptionOnRejection)
Specify whether this interceptor should throw a
MessageRejectedException when its selector does not accept a
Message. |
void |
setTimeout(long timeout)
Specify the timeout value for sending to the discard channel.
|
invokeafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, onInit, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringpublic IdempotentReceiverInterceptor(MessageSelector messageSelector)
public void setTimeout(long timeout)
timeout - the timeout in millisecondspublic void setThrowExceptionOnRejection(boolean throwExceptionOnRejection)
MessageRejectedException when its selector does not accept a
Message. The default value is false meaning that rejected
Messages will be discarded or
enriched with IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE
header and returned as normal to the invocation.proceed().
Typically this value would not be true when
a discard channel is provided, but if it is, it will cause the
exception to be thrown after
the Message is sent to the discard channel,throwExceptionOnRejection - true if an exception should be thrown.setDiscardChannel(MessageChannel)public void setDiscardChannel(MessageChannel discardChannel)
IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE header
and returned as normal to the invocation.proceed(). However,
the 'throwExceptionOnRejection' flag determines whether rejected Messages
trigger an exception. That value is evaluated regardless of the presence
of a discard channel.
If there is needed just silently 'drop' rejected messages configure the
discardChannel to the nullChannel.
discardChannel - The discard channel.setThrowExceptionOnRejection(boolean)public void setDiscardChannelName(String discardChannelName)
IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE header
and returned as normal to the invocation.proceed(). However,
the 'throwExceptionOnRejection' flag determines whether rejected Messages
trigger an exception. That value is evaluated regardless of the presence
of a discard channel.
If there is needed just silently 'drop' rejected messages configure the
discardChannel to the nullChannel.
Only applies if a discardChannel
is not provided.
discardChannelName - The discard channel name.setThrowExceptionOnRejection(boolean)public String getComponentType()
IntegrationObjectSupportgetComponentType in interface NamedComponentgetComponentType in class IntegrationObjectSupportprotected Object doInvoke(MethodInvocation invocation, Message<?> message) throws Throwable
doInvoke in class AbstractHandleMessageAdviceThrowable