Java Reference
In-Depth Information
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/tool
http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
http://www.springframework.org/schema/lang
http://www.springframework.org/schema/lang/spring-lang-3.0.xsd">
<beans:bean class="org.springframework.beans.factory.
config.PropertyPlaceholderConfigurer"
p:location="solution031.properties"
p:ignoreUnresolvablePlaceholders="true" />
<channel id="inboundTweets" />
<beans:bean
id="twitterMessageSource"
class="com.apress.springenterpriserecipes.
springintegration.twitter.TwitterMessageSource"
p:password="${twitter.password}"
p:userId="${twitter.userId}"
/>
<inbound-channel-adapter ref="twitterMessageSource" channel="inboundTweets">
<poller max-messages-per-poll="100">
<interval-trigger interval="10" time-unit="SECONDS" />
</poller>
</inbound-channel-adapter>
<service-activator
input-channel="inboundTweets" ref="twitterMessageOutput" method="announce" />
</beans:beans>
The bold parts are the only salient bits. As in previous examples, you start by declaring a channel
( "inboundTweets" ). Next, you configure an instance of the custom MessageSource implementation
TwitterMessageSource . Finally, you use Spring Integration's inbound-channel-adapter element to wire
the TwitterMessageSource and a poller element. The poller element is configured to run every 10
seconds, and to consume as many as 100 messages each time it runs. That is, if it runs 10 seconds from
now, it will call read() without pause on the MessageSource implementation until it's given a null value,
at which point it will idle until the scheduler starts the cycle again at the next 10-second interval. Thus, if
you have 100 messages, this will consume all of them as quick as possible. Ideally, all the messages will
be processed before the next scheduled pull occurs.
Search WWH ::




Custom Search