Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be the easiest way to implement a custom Inbound Channel Adapter?

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?

like image 261
Ferenc Turi Avatar asked Dec 03 '14 09:12

Ferenc Turi


People also ask

What is Poller in Spring Integration?

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.

What is Spring adapters?

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.

What are the different types of channel adapters?

There are both inbound and outbound adapters, and each may be configured with XML elements provided in the core namespace.

What is inbound channel adapter?

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.


1 Answers

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.

like image 157
Artem Bilan Avatar answered Oct 04 '22 00:10

Artem Bilan