cancel
Showing results for 
Search instead for 
Did you mean: 

Cron event handler - synchronous or asynchronous

Eric_Ace
Confirmed Champ
Confirmed Champ

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?

7 REPLIES 7

Florent_Guillau
World-Class Innovator
World-Class Innovator

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.

Actually - I have a follow-up question

org.nuxeo.ecm.core.scheduler.TestSchedulerService.testScheduleRegistration is one such test.

Thanks again. The code contains the following reference

This file is nuxeo-core/nuxeo-core-event/src/test/resources/OSGI-INF/test-scheduler-config.xml

Thanks.

Eric_Ace
Confirmed Champ
Confirmed Champ

Awesome. Thanks.

Getting started

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.