Spring 集成 SLA 选项

Spring Integration SLA option

我有一个 springboot 集成应用程序,它根据

等参数侦听目录中的文件
startTimeScan
endTimeScan
Days to scan 

我正在使用工作正常的 Cron 表达式,但现在我遇到了一个挑战,即一些客户基本上会有 SLA cutoff 时间,如果文件到那时还没有到达,它会发出警报。

Spring 集成中是否有提供此功能的选项?

是的,AbstractMessageSourceAdvice 实现可以用于这样的逻辑。您只需实施其 afterReceive(Message<?> result, MessageSource<?> source) 并检查 null 的消息。一段时间后,您会发出警报。

唯一的问题是这个建议是从轮询任务中执行的,因此在你的 cron 提到的时间间隔内。不幸的是,没有其他方法可以对丢失的事件做出反应。

https://docs.spring.io/spring-integration/docs/5.0.8.RELEASE/reference/html/messaging-channels-section.html#conditional-pollers