I'm working at implementing a buffer, in order to execute various jobs. I'm working on a Spring-based project. I decided to use Spring Integration to accomplish my aim. I went through a Cafè sample project in order to understand how SI works.
To demonstrate Spring Integration I implemented a table where I dynamically insert jobs to be executed. This table is the "gateway". Then I configured a router and various channels.
What I don't fully understand are the poller elements which have to check if new jobs in the "gateway" are present. Is this correct?
If so, how can I configure the poller? Thanks in advance! Here the xml code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-feed="http://www.springframework.org/schema/integration/feed"
xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
<int:gateway id="usersToSend" service-interface="it.stasbranger.spidly.rss.UsersToSend" />
<int:channel id="channel" />
<int:channel id="providers"/>
<int:router input-channel="providers" ref="providerRouter" method="resolveProviderChannel"/>
<int:channel id="twitterChannel">
<int:queue capacity="10"/>
</int:channel>
<int:service-activator input-channel="twitterChannel" ref="twitterService" method="updateStatusByProfile"/>
<int:channel id="facebookChannel">
<int:queue capacity="10"/>
</int:channel>
<int:service-activator input-channel="facebookChannel" ref="facebookService" method="updateStatusByProfile"/>
<int:channel id="linkedinChannel">
<int:queue capacity="10"/>
</int:channel>
<int:service-activator input-channel="linkedinChannel" ref="linkedinService" method="writeSlogan2Linkedin"/>
<bean id="twitterService" class="it.social.TwitterService"/>
<bean id="facebookService" class="it.social.FacebookService"/>
<bean id="linkedinService" class="it.social.LinkedinService"/>
<int:poller id="poller" default="true">
</int:poller>
FB
<gateway/>
s are not polled, they are "message-driven" in that the caller "sends" a message into the flow using the gateway.
For a polling scenario, use an <int:inbound-channel-adapter/>
which polls a method (on the poller's schedule) looking for work to do.
If the method returns null, the poller goes back to sleep (until the next trigger). If the method returns a value, the message is sent to the channel.