![](/img/trans.png)
[英]Configure a directory scanner on an inbound channel with Spring Integration Java DSL on Spring Integration 5
[英]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.