Admin event send before actual updating the user

Hello.
During integrate Keyclock 11.0.2 I faced with issue related to handling admin events. Description of the issue:
I use custom event handler to send events related to user updating to external service using HttpClient. But in case of editing users using admin cli I got event with not relevant user data. It occured because inside the update endpoint (org.keycloak.services.resources.admin.UserResource#updateUser), the event(org.keycloak.events.admin.AdminEvent) is sent before the user attributes are validated and the user is actually saved (before transaction commit).

Such behavior wasn’t detected in case of user events(org.keycloak.events.Event) sending.

Is it expected behavior?
if so, how to filter events that occurred after the actual user save?

Thank in advise

1 Like

Hello.
Found possible solution using session.getTransactionManager().enlistAfterCompletion(newTransaction);