How to extend and implement TimerProvider?

Hi community,

I have been trying to run a task (let’s say get the users) scheduled daily inside keycloak. I have gone through the TimerProvider interface and implemented it into my custom class (let’s say GetUserProvider).
This custom implementation has to start with keycloak startup. Any ideas on how to go on about this.

Thanks in advance

You can just set it up in the postInit method of any other Provider. Here’s an example:

Thanks @xgp , will check that today. If you don’t mind, I have few more questions. Do I have to use another provider? Can it not be used as a implementation on its own?
For ex: Like in the example, the DatabaseBackupProviderFactory is called on startup, which then calls TimerProvider. Can I call TimerProvider in a similar way and not through another provider?

Edit: Yes, your solution is working fine, thanks. I am able to get the users based on a specific period. Now, I just want to know whether it will work standalone or not.

I don’t know another way to do it other than to load the TimerProvider from a session and schedule your tasks.

Oh! Ok. No worries. Thanks for the help though. :slight_smile: