Spring Integration Inbound-channel-adapter: make one poll and exit

孤人 提交于 2019-12-24 06:39:29

问题


I need to make a small Spring Integration application that synchronize a table from a JDBC source to another one, and I just need to launch that script just once in a while.

I'd like to make one poll from the inbound channel adapter (wait that the message flow through the chain) and exit the application.

I couldn't find any obvious way to do that: any suggestions?


回答1:


@Steve suggests correct solution.

You should make your <poller> with some long fixed-delay do not start a new polling task. Or just stop an <inbound-channel-adapter> just after the polling task is run. For this purpose there is just enough make the channel as <publish-subscribe-channel> and add one more subscriber like:

<outbound-channel-adapter channel="processChannel" expression="@adapter.stop()">

So, this is the first part: How to make only the single poll?

Re. System.exit().

You should add in the end of your flow similar outbound-channel-adapter:

<outbound-channel-adapter channel="endProcessChannel" expression="T(System).exit()">


来源:https://stackoverflow.com/questions/28048770/spring-integration-inbound-channel-adapter-make-one-poll-and-exit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!