4
votes

I need to make process with fork on two path:

  1. Path with user task

  2. Path with service task

see the process picture

Process must move to MoreTasks if ServiceTask complete calculations without waiting user reaction on UserTask.

How can I automaticly complete UserTask after ServiceTask completion without coding on java (only by using camunda bpmn notation)?

I already tried use signal event, and it works, but signal affect all procees instances. I tried use mesage event, but UserTask didn't receive it, probably because I don't have any message hadlers...

2

2 Answers

1
votes

Ok, so this is one of those fairly rare occasions where Camunda removed a userful feature that was in the Activiti engine. In Activiti, it is possible (inside the BPMN) to define if a signal will be thrown globally (the default) or only to the current process instance. While this may not be in line with the BPMN specification, it was extremely useful for scenarios such as yours.

Unfortunately, you can't do this in Camunda. Now, if you don't mind writing a little Groovy script in a task listener, you can limit the signal subscription to only those signals thrown by the current process:

RuntimeService.signalEventReceived(String signalName, String executionId);

Refer to the Camunda docs for more details.

If this is still out of the question, then I would suggest you would wrap the User and Service task in an embedded sub process and throw an exception event immediately after the Service task.

Now, attach an Error Boundary event handler on the embedded sub process.

enter image description here

Something like this (the diagram is from the docs), but without the OR gateway.

When your service task completes, it will throw an error event which will bubble up to the boundary listener and close all tasks in the embedded sub process.

Hope this helps.

0
votes

I once had a similar requirement, but I didn't have the without coding on java constraint, and I had to make this workaround to make it work:

  • I created a service task, developed in JAVA
  • In my service task, I did a task query to get the task from the other branch
  • Launched a new thread to force the task to complete (after some delay)

It wasn't clean, but it works fine, and my customer is happy with the results.