I need a custom adapter which polls a custom resource. (It returns a List of File.)
Is it able to implement and use it in spring integration?
What would be the best practice of implementing such a pollable resource?
PollableChannel interface (such as a QueueChannel ) produces an instance of PollingConsumer . Polling consumers let Spring Integration components actively poll for Messages rather than process messages in an event-driven manner. They represent a critical cross-cutting concern in many messaging scenarios.
1.4 JMS Adapter Spring Integration framework provides inbound and outbound channel adapters for sending and receiving message across different applications in a distributed system. The inbound channel adapters pick up a message from JMS destination topic and publish them to local channels.
There are both inbound and outbound adapters, and each may be configured with XML elements provided in the core namespace.
An "inbound-channel-adapter" element can invoke any method on a Spring-managed Object and send a non-null return value to a MessageChannel after converting it to a Message . When the adapter's subscription is activated, a poller will attempt to receive messages from the source.
See the <inbound-channel-adapter>
:
<int:inbound-channel-adapter ref="source1" method="method1" channel="channel1">
<int:poller fixed-rate="5000"/>
</int:inbound-channel-adapter>
Where source1
is something like:
public class MyService {
public List<File> method1() {
....
}
}
Your method will be invoked each that fixed-rate
interval.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With