public class MessageSourcePollerInterceptor
extends org.springframework.messaging.support.ChannelInterceptorAdapter
implements org.springframework.beans.factory.InitializingBean
ChannelInterceptor
that turns a pollable channel into a "pass-thru channel": if a client calls
receive()
on the channel it will delegate to a MessageSource
to pull the message directly from
an external source. This is particularly useful in combination with a message channel in thread scope, in which case
the receive()
can join a transaction which was started by the caller.Constructor and Description |
---|
MessageSourcePollerInterceptor()
Convenient default constructor for configuration purposes.
|
MessageSourcePollerInterceptor(org.springframework.integration.core.MessageSource<?> source) |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Asserts that mandatory properties are set.
|
boolean |
preReceive(org.springframework.messaging.MessageChannel channel)
Receive from the
MessageSource and send immediately to the input channel, so that the call that we are
intercepting always a message to receive. |
void |
setChannel(org.springframework.messaging.MessageChannel channel)
Optional MessageChannel for injecting the message received from the source (defaults to the channel intercepted
in
preReceive(MessageChannel) ). |
void |
setMessageSource(org.springframework.integration.core.MessageSource<?> source) |
public MessageSourcePollerInterceptor()
public MessageSourcePollerInterceptor(org.springframework.integration.core.MessageSource<?> source)
source
- a message source to poll for messages on receive.public void setChannel(org.springframework.messaging.MessageChannel channel)
preReceive(MessageChannel)
).channel
- the channel to setpublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
InitializingBean.afterPropertiesSet()
public void setMessageSource(org.springframework.integration.core.MessageSource<?> source)
source
- a message source to poll for messages on receive.public boolean preReceive(org.springframework.messaging.MessageChannel channel)
MessageSource
and send immediately to the input channel, so that the call that we are
intercepting always a message to receive.preReceive
in interface org.springframework.messaging.support.ChannelInterceptor
preReceive
in class org.springframework.messaging.support.ChannelInterceptorAdapter
ChannelInterceptorAdapter.preReceive(MessageChannel)