EventListenerProvider : how to force the rollback?

I have an EventListenerProvider that forwards all events to rabbitmq for consumption by other apps.

When I use EventListenerTransaction + enlistAfterCompletion and I throw an exception, the transaction is not rollbacked (which is normal) BUT it causes an InternalServerError and keycloak becomes completely useless

Now, if I do NOT use the EventListenerTransaction and I throw an exception, the exception is logged BUT the transaction is also NOT rollbacked and keycloak keeps running…

My use case is to rollback the transaction in case of error for all events except login and code_to_token (i.e I want to rollback register, verify_email, profile_update, …)

How can I do that ?

Please note that the javadoc (EventListenerProvider (Keycloak Docs Distribution 13.0.1 API)) EXPLICITLY says the transaction pattern is allowed :

Implementors can leverage the fact that the onEvent and onAdminEvent are run within a running transaction. Hence, if the event processing uses JPA, it can insert event details into a table, and the whole transaction including the event is either committed or rolled back.

But at the same time it also says that the onEvent and onAdminEvent should not throw

void onEvent(Event event)

Called when a user event occurs e.g. log in, register.

Note this method should not do any action that cannot be rolled back, see EventListenerProvider javadoc for more details.

Any pointer appreciated