Recursive service task call

cancel
Showing results for 
Search instead for 
Did you mean: 
gopi_chitturi
Active Member

Recursive service task call

Hi,

I have an activiti that I would be triggering which is executed in asynchronous mode. I would need to keep checking the status for the job and when it reaches either a success/failure state, I would need to go to next task. How can I achieve this? Any suggestions?

5 Replies
pault
Active Member II

Re: Recursive service task call

When you say it is executing in async mode, is that a service task with  property activiti:async set to true ? If so is there a reason you are using async mode ?

I've had a similar situation, trying to see if it may be relevant.

gopi_chitturi
Active Member

Re: Recursive service task call

My whole process would run in async mode. To achieve this, I have set the activiti:async to true just for the first task in the process so that the rest of the steps/tasks would also be running in the async mode.

But the question I asked is for a step in the process where I am calling an ETL job that would take a while to complete. As soon as the service call is made to ETL component, it schedules the job and provides an id to track the status back. So, for me as soon as the I make the first call to trigger the job, I have to keep checking the status at regular intervals to see the status and make progress in the process.

I hope I clarified your question. For now, I am checking the status using the Java Thread.sleep() method and when the status is either success/failure, 

gopi_chitturi
Active Member

Re: Recursive service task call

Sorry posted before completing the message. 

But with the current approach, I can't restart the process when something fails abruptly. Pls let me know if you have any additional questions.

pault
Active Member II

Re: Recursive service task call

I understand, so not sure if this is any help, but I have an event listener that needs to run code its own thread so I can safely use the engine API. I don't believe you can use the async flag on a listener, so I start a new thread myself and use a synchronisation object and wait / notify so the original thread waits and I can check if it was a sucess or failure.

As your ETL step could be a long transaction, you can also change the transaction timeout I believe, I haven't needed that myself but have seen it mentioned in the user guide.

gopi_chitturi
Active Member

Re: Recursive service task call

Thanks PaulT _‌! I will check that.