繁体   English   中英

Spring Integration Java DSL:文件入站异常传播

[英]Spring Integration Java DSL: file inbound exception propagation

鉴于以下文件入站:

IntegrationFlows.from(s -> s
                        .file(directory, new LastModifiedFileComparator())
                        .patternFilter(inputFileNamePattern)
                        .preventDuplicates(),
                      e -> e.poller(p -> p.trigger(filePollerTrigger))
)

并且在某些时间超出范围的情况下引发异常的触发器,如何接收引发的异常?

它会出现在流异常通道还是入站特定错误处理程序中

在Java DSL中处理它的正确方法是什么?

提前致谢。

trigger.nextExecutionTime()引发的异常导致轮询任务停止,或者如果听起来更好,则不重新计划轮询任务:

public ScheduledFuture<?> schedule() {
    synchronized (this.triggerContextMonitor) {
        this.scheduledExecutionTime = this.trigger.nextExecutionTime(this.triggerContext);
        if (this.scheduledExecutionTime == null) {
            return null;
        }
        long initialDelay = this.scheduledExecutionTime.getTime() - System.currentTimeMillis();
        this.currentFuture = this.executor.schedule(this, initialDelay, TimeUnit.MILLISECONDS);
        return this;
    }
}

如代码所示,它完全等效于触发器中的null 我们只是从重新计划循环中退出。

考虑在自定义Trigger实现异常处理逻辑,作为该目标对象的包装。 例如ErrorHandlingTrigger

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM