Forums de discussion

"commit" in activiti flow under liferay

Balázs Csönge, modifié il y a 9 années.

"commit" in activiti flow under liferay

Regular Member Publications: 107 Date d'inscription: 10/11/14 Publications récentes
Hi,

I hope Alexey Kakunin will see this post, and can reply emoticon

We using the new version of activity integrated under Liferay CE 6.2. We have an approval flow which contains custom java codes (initiated via listeners). As I "feel" a transaction can live:
- from flow start to flow end without any human task
- from start to human task
- from human task to human task
- from human task till the end.
In the flow, before human task or after a human task, we have to call longer running java methods. We not want to do in asynchronous way, because we have to continue the processin based on the result of the call. But using synchronous way, the liferay UI has to wait the end of this kind of processing, which is not good. We need to make a solution, where user can get the control back after his activity on UI, but the flow side processing must continue.

Is any good way to make inner commit, during the processing?

Our backdoor solution can be: We placing a fake user task to those places, where we need to call long running methods, and we assign it to a dummy user. We bind a listener to this user task start event, and we call the long running method, and when the method returns, we complete the task via java code, and send some user or e-mail notifications if needed, about the result of the long running method. In this case when the processing reach this fake task, user can get the control back.

Is it a better, more "correct" solution for this problem?

Regards

Balázs
Balázs Csönge, modifié il y a 9 années.

RE: "commit" in activiti flow under liferay (Réponse)

Regular Member Publications: 107 Date d'inscription: 10/11/14 Publications récentes
Meanwhile I found the "by-the-book" way in the Activiti user guide under chapter 8.7. Transactions and Concurrency.

So, instead of placing fake user task into the flow, I have to place a script task, which will initiate the long running call, and I have to set Asychronous attribute to true.

I tested it with the following "long running code":
public class SubProcessFinalActions implements JavaDelegate {

	private static Log log = LogFactoryUtil.getLog(SubProcessFinalActions.class);
	
	@Override
	public void execute(DelegateExecution execution) throws Exception {
		log.info("SubProcessFinalActions has been started. " + new Date());
		Thread.sleep(60000);
		log.info("SubProcessFinalActions has been finished. " + new Date());
	}

}

One service task was placed at the begining of the flow, other was placed after a user task. In both cases, the user got the UI control back immediatelly after the process start/user task complete, the long running process started, and all stuff after the call has been waited the execution of the long running call.

Other:

Sorry, but this post was made under the wrong section/topic. emoticon I thought, the solution can be depend from the integration between liferay and activiti engine, and Alexey will be the target person, who knows everything about this integration.
Balázs Csönge, modifié il y a 9 années.

RE: "commit" in activiti flow under liferay

Regular Member Publications: 107 Date d'inscription: 10/11/14 Publications récentes
After my last post we started to use the service task in Asychronous mode as a transaction separator. Therefore liferay UI will get the control back before long running actions started.

But we had to realize, if any exception occures after the new transaction border, the engine tries to rerun the execution 2 more times. As I understand, It is some built in Activiti feature.
I read about the failedJobRetryTimeCycle attribute. The Activiti diagram editor, what I use, doesn't contain any option to set it. But In XML editor mode I extended the related serviceTask tag with the following:
        <extensionelements>
          <activiti:failedjobretrytimecycle xmlns:activiti="http://activiti.org/bpmn">R0/PT1S</activiti:failedjobretrytimecycle>
        </extensionelements>

The value was a tip, I did not found any documentation which exactly tell me what should I set if I want zero retry.

Remark: I tried to use Manual Task or Timer Catching Event in Asychronous mode as a transaction separator, but those solutions ignored the failedJobRetryTimeCycle attribute completelly and always tried to run the failed transaction 3 times.

So usage of the Service task seems ok, but sadly not 100%. I have a user task with Timer Boundary Event, which does not cancel the task, just a reminder mail task has been initiated on that thread. There is a listener related to that mail task too (which sends portal notification via java code). If any exception occures during the execution of the listener code, the engine retries to process it 2 more times...