Class IdempotentReceiverInterceptor
- All Implemented Interfaces:
- Advice,- Interceptor,- MethodInterceptor,- Aware,- BeanFactoryAware,- BeanNameAware,- InitializingBean,- ApplicationContextAware,- ComponentSourceAware,- ExpressionCapable,- HandleMessageAdvice,- NamedComponent
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.
- Since:
- 4.1
- Author:
- Artem Bilan, Gary Russell
- See Also:
- 
Field SummaryFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, logger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected ObjectdoInvoke(MethodInvocation invocation, Message<?> message) Subclasses may implement this method to provide component type information.voidsetDiscardChannel(MessageChannel discardChannel) Specify a channel where rejected Messages should be sent.voidsetDiscardChannelName(String discardChannelName) Specify a channel name where rejected Messages should be sent.voidsetThrowExceptionOnRejection(boolean throwExceptionOnRejection) Specify whether this interceptor should throw aMessageRejectedExceptionwhen its selector does not accept a Message.voidsetTimeout(long timeout) Specify the timeout value for sending to the discard channel.Methods inherited from class org.springframework.integration.handler.advice.AbstractHandleMessageAdviceinvokeMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, onInit, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
- 
Constructor Details- 
IdempotentReceiverInterceptor
 
- 
- 
Method Details- 
setTimeoutpublic void setTimeout(long timeout) Specify the timeout value for sending to the discard channel.- Parameters:
- timeout- the timeout in milliseconds
 
- 
setThrowExceptionOnRejectionpublic void setThrowExceptionOnRejection(boolean throwExceptionOnRejection) Specify whether this interceptor should throw aMessageRejectedExceptionwhen its selector does not accept a Message. The default value isfalsemeaning that rejected Messages will be discarded or enriched withIntegrationMessageHeaderAccessor.DUPLICATE_MESSAGEheader and returned as normal to theinvocation.proceed(). Typically this value would not betruewhen 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,- Parameters:
- throwExceptionOnRejection- true if an exception should be thrown.
- See Also:
 
- 
setDiscardChannelSpecify a channel where rejected Messages should be sent. If the discard channel is null (the default), duplicate Messages will be enriched withIntegrationMessageHeaderAccessor.DUPLICATE_MESSAGEheader and returned as normal to theinvocation.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 discardChannelto thenullChannel.- Parameters:
- discardChannel- The discard channel.
- See Also:
 
- 
setDiscardChannelNameSpecify a channel name where rejected Messages should be sent. If the discard channel is null (the default), duplicate Messages will be enriched withIntegrationMessageHeaderAccessor.DUPLICATE_MESSAGEheader and returned as normal to theinvocation.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 discardChannelto thenullChannel.Only applies if a discardChannelis not provided.- Parameters:
- discardChannelName- The discard channel name.
- Since:
- 5.0.1
- See Also:
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- IntegrationObjectSupport
 
- 
doInvoke- Specified by:
- doInvokein class- AbstractHandleMessageAdvice
- Throws:
- Throwable
 
 
-