简体   繁体   English

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

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

Given the following file inbound: 鉴于以下文件入站:

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

and the trigger that throws exception in case certain time was overreached, how does one receives exception that was thrown? 并且在某些时间超出范围的情况下引发异常的触发器,如何接收引发的异常?

Will it appear in flow exception channel or in inbound specific error handler ? 它会出现在流异常通道还是入站特定错误处理程序中

What is the correct way to deal with it in java dsl? 在Java DSL中处理它的正确方法是什么?

Thanks in advance. 提前致谢。

The exception thrown from the trigger.nextExecutionTime() causes the polling task to be stopped, or not rescheduled if that sounds better: 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;
    }
}

As you see by code it is fully equivalent to the null from the trigger. 如代码所示,它完全等效于触发器中的null We just exit from the rescheduling loop. 我们只是从重新计划循环中退出。

Consider to implement the exception handling logic in the custom Trigger as a wrapper around that target one. 考虑在自定义Trigger实现异常处理逻辑,作为该目标对象的包装。 For example ErrorHandlingTrigger . 例如ErrorHandlingTrigger

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

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