Integrating camunda BPM with an external task management application

1,265 views
Skip to first unread message

Vadym Elkind

unread,
Jun 18, 2015, 7:29:17 AM6/18/15
to camunda-...@googlegroups.com
Hello guys,

I need your advice. Currently I'm playing with camunda BPM in order to find an approach to integrate it with an external application.
This application is web based and used for managing (claiming, editing, closing etc.) of human tasks.

So far I could implement the following scenario:
The human tasks that should be processed in the mentioned external application are modelled as asynchronous service(!) tasks (extending AbstractBpmnActivityBehavior class) in camunda Modeler.
The execute() method of such tasks calls a SOAP web service that purpose is to create the task in the the external application. After this the task can be processed in the external app.
As soon the task was finished/closed in the external app this fact is signalized to camunda BPM using the REST API.
The corresponding service task is from now on also finished in camunda BPM and the engine goes ahead with the execution of this particular process instance.

This is how it graphically looks like:

It works fine so far. The only thing which I don't like in this integration approach is that the human tasks are displayed as service tasks in BPMN diagrams.

Is there some trick to let this concrete service tasks be displayed as human tasks in the diagrams? Or is there any other approach to integrate an external application in order to process

human tasks there?


Thanks in advance.


Vadym



thorben....@camunda.com

unread,
Jun 18, 2015, 7:54:45 AM6/18/15
to camunda-...@googlegroups.com
Hi Vadym,

You may use a bpmn parse listener and implement the method parseUserTask. Then you can replace each user task's activity behavior with your service task behavior. See [1] for an example of a parse listener.

Another idea could be overriding the class org.camunda.bpm.engine.impl.persistence.entity.TaskManager and implementing the methods such that instead of accessing the process engine database for inserting/updating/deleting tasks, they talk to your external task application. Then, in theory, you can reuse the engine's task API to work with your external task management application. Replacing the task manager can in general be done by implementing org.camunda.bpm.engine.impl.interceptor.SessionFactory and adding it in the process engine configuration to the list property customSessionFactories. Please let me know if you need some more code pointers in that direction. I also think that this solution is more complex than the first one.

Cheers,
Thorben

thorben....@camunda.com

unread,
Jun 18, 2015, 7:55:34 AM6/18/15
to camunda-...@googlegroups.com
Message has been deleted

Vadym Elkind

unread,
Jun 21, 2015, 8:00:56 AM6/21/15
to camunda-...@googlegroups.com
Hi Thorben,

thank you for this advices. It would be nice to have also some pointers for the second, more complex approach.

Thanks in advance.

Regards
Vadym

thorben....@camunda.com

unread,
Jun 22, 2015, 3:23:22 AM6/22/15
to camunda-...@googlegroups.com
Hi Vadym,

Here's a rough outline:

1: Subclass org.camunda.bpm.engine.impl.persistence.entity.TaskManager [1]
2: Implement its methods based on your external task management system. You may not need to implement all operations depending on which API you want to be able to use. Have a look at the usage of the TaskManager methods to understand which method is used when.
3: Implement org.camunda.bpm.engine.impl.interceptor.SessionFactory [2] such that getSessionType returns the class TaskManager and openSession returns an instance of your subclass
4: In the process engine configuration, add your custom session factory to the property customSessionFactories when you create a process engine

Optional ideas:
5: Some kind of caching mechanism. For example, the default task manager selects a task at most once throughout a transaction

Ideally, the engine then integrates with your task management system and you can use the engine's APIs to access it. Some considerations: First, the above mentioned classes are all internal API, meaning their structure can change with any future release. Second, the engine is built with a relational database for task management as the primary use case. That means, the task manager may expose methods that are cheap to implement with the engine's relational database schema but may be harder with an external task management system. Third, you may have to deal with the problem of engine transactions that roll back in which case your custom task manager does not participate by default. You may have to solve the last issue in any of the solution approaches.

I hope that helps getting a feeling for that direction.

Cheers,
Thorben

[1] https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/TaskManager.java
[2] https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/interceptor/SessionFactory.java

Vadym Elkind

unread,
Jun 24, 2015, 9:39:33 AM6/24/15
to camunda-...@googlegroups.com
Hello Thorben,

I'm very thankful for this hints. I gonna try it out.

Greetings,
Vadym
Reply all
Reply to author
Forward
0 new messages