DEV Community

Discussion on: Building an Event Listener SPI (Plugin) for KeyCloak

Collapse
 
smotastic profile image
smotastic

Hey, nice article.
You wrote that
"An error in Provider will simply go to the logs and rest of Keycloak will function normally"
Do you know if there is any way to knowingly abort / rollback the executed Keycloak-functionality which triggered my event?

If for example my call to my external API or database fails, i might want to abort the current action.

I tried throwing an exception, but the implementation for the AdminEvent will just catch all Exceptions and log them.

try {
  store.onEvent(eventCopy, includeRepresentation);
} catch (Throwable t) {
  ServicesLogger.LOGGER.failedToSaveEvent(t);
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
adwaitthattey profile image
Adwait Thattey

Sorry. I am not aware about any way to do this. As far as I understand, this event capturing and logging happens parallels and can't affect the original execution...
I may be wrong. I wrote this more than a year ago and haven't worked on Keycloak or java from a long time.