cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti Wait and Trigger implementation

saurabh_biet
Champ in-the-making
Champ in-the-making
I am reading and learning Activiti. While doing the same I tried to incorporate a workflow where:
1. Start event triggers an EMAIL having 2 links approve and reject
2. Once user approves/reject, I want to update the status of the same in database.
3. Irrespective of approve/reject downstream service is notified about the same.

Workflow diagram: https://s31.postimg.org/vzbvtmxgr/Screen_Shot_2016_07_26_at_7_56_43_PM.png

So far, what I understood, I created a service-task which is responsible for generating the email. - WORKS FINE (I am using downstream service of mine to generate the email with approve and reject buttons).

After this I add a Boundary-Signal to the task so that the workflow waits (I assumed that the state is persisted to H2).

When the user clicks on approve/reject buttons, I get the call on my REST service and get the activiti execution-id.

I tried to trigger the signal so that the workflow can start but failed to do so.

I tried the following code:

getRuntimeService().signalEventReceived("Approve Or Reject Signal", request.getExecutionId(), activitiContext);

But the above statement ends up in an error "org.activiti.engine.ActivitiObjectNotFoundException: Cannot find execution with id '9'"


I have 2 questions:
1. Am I doing anything wrong here?
2. I tried to browse and got to know that "receive-task" should be used but failed to find any example of how it can be used?


Any help will be appreciated.
2 REPLIES 2

jbarrez
Star Contributor
Star Contributor
> After this I add a Boundary-Signal to the task so that the workflow waits

This is not correct. A service task will always continue. The signal doesn't do anything here. Use the 'intermeidate signal catch' event to do what you want instead.

saurabh_biet
Champ in-the-making
Champ in-the-making
Thanks for your comment.
I was able to fix this. At times over-reading docs time and again helps Smiley Happy

I have changed my flow. Now once the service task ends, I invoke the receive task.
To continue a process instance that is currently waiting at such a Receive Task, the runtimeService.signal(executionId) must be called using the id of the execution that arrived in the Receive Task.

It works.

Thanks!