listen to events when a task is conplete
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2015 03:49 PM
Hi. How do I listen for tasks being completed, and how can I differentiate between the various tasks that might exist for a process definition?
Labels:
- Labels:
-
Archive
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2015 05:37 PM
Check out the 3.18. Event handlers section of the user guide
http://activiti.org/userguide/index.html
To be notified only when a task completes, set the typedEventListeners property of processEngineConfiguration to a Map with a key TASK_COMPLETED and value of List containing your class that implements org.activiti.engine.delegate.event.ActivitiEventListener. Your class's onEvent method will get called with an instance of org.activiti.engine.delegate.event.ActivitiEvent each time a task completes.
The ActivitiEvent has a getProcessDefinitionId that you can use to differentiate between different process definitions. To differentiate between tasks, cast ActivitiEvent to org.activiti.engine.delegate.event.impl.ActivitiEntityEventImpl. You can then get the task instance using the getEntity method of ActivitiEntityEventImpl (which, of course, you will need to cast). From the task instance you can use the task name or task definition key to differentiate between tasks.
http://activiti.org/userguide/index.html
To be notified only when a task completes, set the typedEventListeners property of processEngineConfiguration to a Map with a key TASK_COMPLETED and value of List containing your class that implements org.activiti.engine.delegate.event.ActivitiEventListener. Your class's onEvent method will get called with an instance of org.activiti.engine.delegate.event.ActivitiEvent each time a task completes.
The ActivitiEvent has a getProcessDefinitionId that you can use to differentiate between different process definitions. To differentiate between tasks, cast ActivitiEvent to org.activiti.engine.delegate.event.impl.ActivitiEntityEventImpl. You can then get the task instance using the getEntity method of ActivitiEntityEventImpl (which, of course, you will need to cast). From the task instance you can use the task name or task definition key to differentiate between tasks.
