cancel
Showing results for 
Search instead for 
Did you mean: 

How to have only one instance of a service Task running

mimani
Champ in-the-making
Champ in-the-making
HI,

I am developing a workflow using activiti-5.15.1, where I am picking some data from a system and doing processing on it. I am using a Service Task in the beginning of the flow to fetch data from the other system. Now, there is possibility, that if multiple processes of this workflow runs in parallel, the ServiceTask may also run in parallel and get same data in two different instances.

Is there a way I can restrict so that only one instance of this Service Task runs.

Any help will be appreciated.

Regards,
Mimani
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
This looks to me like the data needs to be fetched from a typical queue (eg JMS) to guarantee that only one consumer can take the data

mimani
Champ in-the-making
Champ in-the-making
This is not just about reading serially but I want to block the read until This service task completes and I mark the data as processed.

So I was thinking, I will fetch the data and after processing, mark the data in the service task as processed so if only one service task executes at a time, It will never fetch same data in different processes. I am not sure what should be correct approach for this case.

jbarrez
Star Contributor
Star Contributor
I'm not sure if I'm fully following what you are trying to do here … but as far as I read it, you should be able to do this with a typical queue implementation. You need one producer that puts the data on the queue, and then the queue guarantees only one will process it.