英文:
How to make Spring Integrations jdbc inbound channel adapter to poll new data?
问题
我已经编写了如下的JDBC入站适配器:
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>
这个工作正常。但是如果在整天内向Trade表中添加了新记录,新记录不会被检索。为了使其轮询新数据,需要进行哪些更改?这个适配器将在5个工作日(周一至周五)内保持运行,应该读取所有新记录。
英文:
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.
答案1
得分: 1
这在参考文档中有解释:
[...] 适配器还有一个UPDATE语句,用于标记记录为已处理,以便它们不会在下一次轮询中出现。
还有一个显示如何使用它的代码片段:
<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)" />
英文:
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)" />
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论