Reputation: 579
I'm trying to implement a Poller with a DynamicPeriodicTrigger which would backoff (increase duration between polls) if the pollable message source (e.g. FTP server) becomes unavailable, a bit like what is already done through SimpleActiveIdleMessageSourceAdvice but the advice would need to be able to catch the exception thrown during the poll. Unfortunately the invoke method of AbstractMessageSourceAdvice is final, so I can't overwrite it.
I also tried a different approach which is to catch the poll exception by having the poller forward it to an error-channel, where I can increase the duration of the trigger (that part works ok). The problem in that case is how to reset the trigger the next time the poll succeed (i.e. the message source is available again). I can't just reset the trigger in a downstream handler method because the message source may have recovered, but there could still be no message available (in which case my downstream handler method is never called to reset the duration of the trigger).
Thank you very much advance for your expertise and your time. Best Regards
Upvotes: 1
Views: 134
Reputation: 174809
You don't have to override AbstractMessageSourceAdvice
; as you can see its invoke
method is pretty trivial; just copy it and add functionality as needed (just be sure to implement MessageSourceMutator
so it's detected as a receive-only advice).
Maybe it's as simple as moving the invocation.proceed()
to a protected non-final method.
If you come up with something that you think will be generally useful to the community, consider contributing it back to the framework.
Upvotes: 1