Class MessageSourcePollerInterceptor
- java.lang.Object
- org.springframework.messaging.support.ChannelInterceptorAdapter
- org.springframework.batch.integration.chunk.MessageSourcePollerInterceptor
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean,org.springframework.messaging.support.ChannelInterceptor
public class MessageSourcePollerInterceptor extends org.springframework.messaging.support.ChannelInterceptorAdapter implements org.springframework.beans.factory.InitializingBeanAChannelInterceptorthat turns a pollable channel into a "pass-thru channel": if a client callsreceive()on the channel it will delegate to aMessageSourceto pull the message directly from an external source. This is particularly useful in combination with a message channel in thread scope, in which case thereceive()can join a transaction which was started by the caller.- Author:
- Dave Syer
Constructor Summary
Constructors Constructor Description MessageSourcePollerInterceptor()Convenient default constructor for configuration purposes.MessageSourcePollerInterceptor(org.springframework.integration.core.MessageSource<?> source)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Asserts that mandatory properties are set.booleanpreReceive(org.springframework.messaging.MessageChannel channel)Receive from theMessageSourceand send immediately to the input channel, so that the call that we are intercepting always a message to receive.voidsetChannel(org.springframework.messaging.MessageChannel channel)Optional MessageChannel for injecting the message received from the source (defaults to the channel intercepted inpreReceive(MessageChannel)).voidsetMessageSource(org.springframework.integration.core.MessageSource<?> source)
Constructor Detail
MessageSourcePollerInterceptor
public MessageSourcePollerInterceptor()
Convenient default constructor for configuration purposes.
MessageSourcePollerInterceptor
public MessageSourcePollerInterceptor(org.springframework.integration.core.MessageSource<?> source)
- Parameters:
source- a message source to poll for messages on receive.
Method Detail
setChannel
public void setChannel(org.springframework.messaging.MessageChannel channel)
Optional MessageChannel for injecting the message received from the source (defaults to the channel intercepted inpreReceive(MessageChannel)).- Parameters:
channel- the channel to set
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.ExceptionAsserts that mandatory properties are set.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.Exception- See Also:
InitializingBean.afterPropertiesSet()
setMessageSource
public void setMessageSource(org.springframework.integration.core.MessageSource<?> source)
- Parameters:
source- a message source to poll for messages on receive.
preReceive
public boolean preReceive(org.springframework.messaging.MessageChannel channel)
Receive from theMessageSourceand send immediately to the input channel, so that the call that we are intercepting always a message to receive.- Specified by:
preReceivein interfaceorg.springframework.messaging.support.ChannelInterceptor- Overrides:
preReceivein classorg.springframework.messaging.support.ChannelInterceptorAdapter- See Also:
ChannelInterceptorAdapter.preReceive(MessageChannel)