How to use EventListenerProvider the right way with Spring-Boot

Hello all,
I need some advice on the implementation of a use case.

I have developed a spring-boot application and use Keycloak as identity provider. I would like to get notified anytime a user successfully registers / logs in etc…

I have come so far to implement an EventlistenerProvider and EventlistenerProviderFactory. However, as far as I understand it I need to put the jar on my Keycloak servers provider folder so that they are registered.

Since I also use application logic in the EventListenerProvider or functions from the service layer I find it a bit strange to place the whole application there.

What would be the alternative or have I misunderstood something here?

2 Likes

The EventlistenerProvider will run inside Keycloak. If you need to execute some external logic in another application, it is recommended that you send a message to that application from your EventlistenerProvider implementation. One approach is to send an HTTP request. I’ve got some helpers to do that here GitHub - p2-inc/keycloak-events: Useful Keycloak event listener implementations and utilities.

Hey @xgp,

thanks for the quick response. Do you know, if i can use anything else instead of of HTTP requests? Is there any chance using messaging or similar technology?

You can use anything you want. There are various implementations out there for using things like MQTT, SQS, Kafka. E.g.:

It’s all based on what you put in your event listener implementation.

1 Like

Thanks mate, I think that solves my problem.

What’s the point of using eventListener if it can be done with just a helper class? Any specific reason why you are using eventListener?