distributed-lock icon indicating copy to clipboard operation
distributed-lock copied to clipboard

Use Spring scheduler if enabled instead of overriding

Open middagj opened this issue 2 years ago • 0 comments

Spring creates its own TaskScheduler bean if @EnableScheduler is used. This library overrides Spring's TaskSchduler because it uses the same name/type and therefore Spring's bean is not used. This is the easiest way to deal with it, the only downside is that if people use @Scheduled without @EnableScheduler it will still work with this libary's TaskScheduler. The other is that you might want to use a dedicated TaskScheduler for refreshing. For the latter you could always override the LockBeanPostProcessor. I guess that would be applicable for such an advanced use case.

Alternatives:

  • Use dedicated task scheduler with a different bean name, so it is easy extendable (downside, you cannot use Spring's one easily)

middagj avatar May 18 '22 12:05 middagj