简体   繁体   中英

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?

Thanks in advance.

The exception thrown from the trigger.nextExecutionTime() causes the polling task to be stopped, or not rescheduled if that sounds better:

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. 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. For example ErrorHandlingTrigger .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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