0

I have a springboot integration application that listen for the files in the directory based on some parameter like

startTimeScan
endTimeScan
Days to scan 

I am using Cron expression that works fine but now I have a challenge that some of the clients would have SLA cutoff time basically if the file don't come by that time it will raise an alert.

Is there any option in Spring Integration that kind of provide this feature?

Makky
  • 17,117
  • 17
  • 63
  • 86

1 Answers1

1

Yes, the AbstractMessageSourceAdvice implementation can be used for such a logic. You just need to implement its afterReceive(Message<?> result, MessageSource<?> source) and check for the message for null. After some period you raise an alert.

Only the problem that this advice is executed from the polling task, therefore in the interval mentioned by your cron. Unfortunately there is no other way react to the missing event.

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

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • So it will not work with cron expression because technically cron expression will also poll just specified time ? – Makky Oct 04 '18 at 15:17
  • For example it will poll every 30 seconds between 9am and 12pm now if the file even does not arrive by 1pm then raise alert – Makky Oct 04 '18 at 15:18
  • That's correct. I don't know how to explain yet: we perform the poll only by the cron expression. And only during this action we can check for the file presence. Otherwise you need a separate poller with different polling interval. – Artem Bilan Oct 04 '18 at 15:19
  • OK. I can create another poller on top of that poller that actually starts after the end time and check if have receive the file or not then raise alert – Makky Oct 04 '18 at 15:24