Search code examples
javaspring-bootspring-integrationspring-jdbc

How to make Spring Integrations jdbc inbound channel adapter to poll new data?


I have written jdbc inbound adapter as below

int-jdbc:inbound-channel-adapter id="jdbcInbound"
                                      channel="channel"
                                      data-source="dataSource"
                                      query="SELECT * FROM Trade"
                                      row-mapper="TradeRowMapper"
                                      max-rows-per-poll="100">
        <int:poller fixed-delay="60000" time-unit="SECONDS"/>
    </int-jdbc:inbound-channel-adapter>

This works fine. But if new records are added to the Trade table say throughout the day, new records are not picked up. What changes do I need to make for it poll new data as well. This adapter is going to keep running for 5 business days monday-friday - and it should read all new records as well.


Solution

  • This is answered in the reference docs:

    [...] the adapter also has an UPDATE statement that marks the records as processed so that they do not show up in the next poll.

    There is also a snippet showing how to use it:

    <int-jdbc:inbound-channel-adapter query="select * from item where status=2"
        channel="target" data-source="dataSource"
        update="update item set status=10 where id in (:id)" />