To give you quick overview on what is referred to as Bonita here, Bonita is referred to as BonitaSoft BPM Tool. As per BonitaSoft corporate website, Bonita BPM improves business operations by connecting people, processes, and information systems into easily managed applications. The blog aims to highlight some of the aspects of Bonita BPM REST API and, some of the reasons due to which one would want to go with REST based integration with Bonita BPM.
Those of you working with BonitaSoft tool including Bonita Portal for accessing workflow applications on top of BonitaSoft workflow engine & Bonita Studio for creating workflows, may have been exploring to find out ways and means to have your custom apps having non-Bonita UI integrate with Bonita workflow engine as underlying workflow runtime. This integration can be achieved using multiple different ways including following:
- Using Mix ‘N’ Match: Deploy Bonita Jar with your application libraries and invoke Bonita Java API directly from within your Java application like any other java library. The advantage to this is that you are saved from the hassles of doing web service based integration with Bonita workflow engine running on different server along with related issues such as security, latency etc. However, this may end up making architecture a bit complex as in case of issues such as performance, and errors, it would be difficult to a) isolate the bug and b) fix without bringing down the application. This may also be seen as violation of separation of concerns. From scalability perspective, the scalability need of one (either application or Bonita) would force both the bundles to be deployed jointly and any change would bring lot of complexity in terms of bringing down the server, uploading the changes, and bringing up the server. Thus, if you are working with large complex set of monolithic applications for different line of business, it would be advisable to go for REST based integration while deploying Bonita workflow on different set of boxes. This is assuming that REST is the web service architecture standard for your organization.
- Using REST: Deploy Bonita Workflow engine on a separate (or same but different server container) box and have your application invoke Bonita using REST APIs. From architecture perspective, this comes up with advantage of having control on performance and scalability of both, the application and Bonita engine, along with other advantages such as independence of upgrading applications and Bonita. The downside of this would be things that would be required to be done for integrating and managing the integration between your application and Bonita workflow engine.
BonitaSoft supports REST based integration with its workflow engine. Thus, the primary reason one would want to go for REST based integration with Bonita workflow engine is to still remain using your product UI while using Bonita workflow as an underlying engine. Otherwise, you may have to use BonitaSoft Portal Skins which may not align and streamline with your product UI.
Following are some of the things that you could achieve using REST based integration of your web application with Bonita workflow engine:
- Start, stop, resume or suspend a workflow instance. One could actually use Bonita REST Runtime API for this purpose.
- Read work items (task list) for a specified user.
- Read details on independent work items.
- Store work items for a specified user.
- Shows authorized work lists for specified users. One could make use of Management API for this purpose.
Following is a list of common tasks vis-a-vis APIs that one could use:
|Instantiage a process||/API/runtimeAPI/instantiateProcessWithVariables/[Process Name]|
|Set Process Variables||/API/runtimeAPI/setProcessInstanceVariable/[processName]|
|Complete a Task||/API/runtimeAPI/executeTask/[taskName]/false|
|Get a Task||/API/queryRuntimeAPI/getTask/[taskName]|
|Get Tasks for a User||/API/queryRuntimeAPI/getLightTaskListByUserId/[username]/READY|
|Get Variables for a Process||/API/queryRuntimeAPI/getProcessInstanceVariables/[processid]|
|Get Active Tasks||/API/queryRuntimeAPI/getLightTaskListByActivityState/READY|
Just to mention some of key categories of Bonita REST API:
- Management API (Deploy process, ACLs for users for process access)
- QueryDefinition API (Processes and tasks information)
- Identify API (user management including creating users)
- Runtime API (Start/stop process, change process variable, validate user tasks)
- QueryRuntime API (Information on running processes, users’ tasks, values of process variable)
- BAM API (Information on performance indicators of various processes)
The diagram below highlights the key APIs as mentioned above and the aspect of these APIs integrating Bonita and custom applications to the services container of Bonita engine.