03-15-2017 09:10 AM
Hello - I have created an event handler for a scheduled event. The handler will perform a long-running operation. Looking through the Nuxeo code, I see various classes implementing AbstractWork for background processing. My question is: should I consider using the AbstractWork code? Or -- will the event already be running on it's own thread by virtue of the fact that it was invoked according to a schedule?
03-15-2017 09:22 AM
A scheduled event should be managed by an asynchronous listener.
If you use a synchronous listener, it will execute in the thread of the Quartz process dealing with the scheduling of that event, and such threads are on purpose kept in very small numbers (to avoid consuming unneeded resources — there's actually just one thread in the default platform, see templates/common/config/quartz.properties
). If you write such a synchronous listener for a scheduled event then it should execute very quickly, but if it needs to it can also do asynchronous Work by passing a subclass of AbstractWork
to the WorkManager
method schedule
.
But directly writing an asynchronous listener (which is implemented using a subclass of AbstractWork
itself) is simpler.
03-15-2017 09:35 AM
Actually - I have a follow-up question
03-15-2017 09:42 AM
org.nuxeo.ecm.core.scheduler.TestSchedulerService.testScheduleRegistration
is one such test.
03-15-2017 12:03 PM
Thanks again. The code contains the following reference
03-15-2017 12:21 PM
This file is nuxeo-core/nuxeo-core-event/src/test/resources/OSGI-INF/test-scheduler-config.xml
03-15-2017 02:22 PM
Thanks.
03-15-2017 09:25 AM
Awesome. Thanks.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.