As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
I have a question regarding the markRollBack method of the Event class. Tracing through AbstractSession.createDocument to EventServiceImpl.fireEvent into a subclass of EventListener - I cannot see how calling markRollBack on the Event inside the listener subclass actually triggers a roll back of the transaction. Should this be mechanism be used for document-based event listeners to initiate rollbacks in exception conditions? I am unable to cause a rollback to happen in the unit test environment (have not yet tried in the local server environment.) I see the markRollBack method used in the org.nuxeo.ecm.user.invite package, and I also see it used in the nuxeo-quota addon. I just don't see the code that actually performs the rollback on the basis of the flag being set in the Event class. Clarification is appreciated on whether this is an appropriate way to manage transactions inside listeners and - if so - how it actually works. Thanks.
markRollBack
Event
AbstractSession.createDocument
EventServiceImpl.fireEvent
EventListener
org.nuxeo.ecm.user.invite
The pattern is to do event.markRollBack() then raise an exception. The framework will then re-raise an generic exception, and then the normal exception handling mechanism of Nuxeo will rollback the transaction.
event.markRollBack()
An alternative is to call event.markBubbleException() then raise a specific exception like RecoverableClientException which will be kept as-is by the framework and can be caught by whoever initiated the event.
event.markBubbleException()
RecoverableClientException
Failing to do either of those, an exception in a synchronous (inline) listener will be caught and logged, but the other ones will still be run and the transaction will continue.
Code for all this is in EventServiceImpl.fireEvent(Event).
EventServiceImpl.fireEvent(Event)