首页 > 解决方案 > 如何在临时基础上触发入站通道适配器?

问题描述

我的配置如下所示,我使用入站通道适配器触发 bean 类以生成每天发送的文件。除了预定的工作之外,我还需要设施来临时运行它。我看不出有什么方法可以做到这一点。

我能想到的唯一方法是获取 SourcePollingChannelAdapter 的实例,设置新触发器(使用新的 cron 表达式)并重新启动端点。让我知道是否有更好的方法来做到这一点。

<int:inbound-channel-adapter ref="xxxTask" method="executeXXXTask" channel="fileOutChannel">
    <int:poller cron="0 30 4 ? * *"/>
</int:inbound-channel-adapter>

标签: javaspringspring-integration

解决方案


你的解决方案没问题。

或者,您可以更频繁地轮询并添加PollSkipAdvice忽略轮询。添加自定义PollSkipStrategy(或使用SimplePollSkipStrategy)来启用/禁用投票。

自定义策略可以使用一次AtomicBoolean.getAndSet()投票(通过触发器设置)。

请参阅文档。另请参阅智能轮询器


推荐阅读