Single execution of an Operation or EventListener

I'm new to Nuxeo and I'm trying to create an operation that manages a list of work to be executed? But only one instance can access the list at any time. From what I understand, each invocation of an operation results in a new instance. I could create a class critical regions (sychonized methods and blocks) but would that be violating the semantics around Operations? That solution only works in the same JVM.

Can an EventListener be configured such that onlyu one instance handles all Events of a particular Event Identifier? Can using the WorkManager help me solve this problem?

Thanks, I scoured the Nuxeo documentaiton and Answers Forum and could not find exactly what I am looking for.

0 votes

1 answers

1390 views

ANSWER



Yes the WorkManager service is designed for that. It's only available since Nuxeo 5.6-RC1 though.

If you want to use it, you should contribute a new queue to the queues extension point with maxThreads set to 1 which will ensure serial execution. Then contribute new Work instances (just inherit from AbstractWork) with the correct category and provide them to the WorkManager service.

In the Admin Center you'll find a Background Work tab allowing you to see what's going on in your queues.

0 votes