Enhance end-developer's usage with the Flowable *Services

Hello,

We are working on a project which actively is using the Flowable engine in order to manage processes. Our business case scenario includes some actions over processes. For instance, abort a process, retry failed process, resume a suspended process, start a new process, etc.
Currently, in order to implement those functionalities one should use the ManagementService, the RuntimeService, the RepositoryService, the HistoryService. Using those services, a lot of deep knowledge in the flowable engine is required in order to fulfil the above actions over a process.
Here is an example:
In order to start a process, one should use the below piece of code:

ProcessDefinitionQuery query = engine.getRepositoryService()
.createProcessDefinitionQuery()
.processDefinitionKey(processDefinitionKey)
.latestVersion();
String processDefinitionId = query.singleResult()
.getId();
ProcessInstance processInstance = engine.getRuntimeService()
.startProcessInstanceById(processDefinitionId, variables);

It will be much easier to just use the following:

engine.getServices().startProcessInstance(processDefinitionKey, variables);

or if an abortion of the process is required(deletion of the process instance):

engine.getServices().abortProcessInstance(processInstanceId); - for aborting processes

or if a retry is needed(for instance, when the process has a failed job and a retry of the failed job is needed):

engine.getServices().retryProcessInstanceExecution(processInstanceId);

of if a resume is necessary(for instance when the process is at receive task):

engine.getServices().resumeSuspendedProcessInstance(processInstanceId);

Do you think that such an simplification is sufficient and could be used?
Please correct me if there is already such mechanisms in the engine :slight_smile: I would be glad to find and use them :slight_smile:

Thanks in advance,
Encho

@enchobelezirev in my opinion the different services offer insight what you can use them for:

  • RuntimeService - service for managing runtime state of a process
    • createProcessInstanceBuilder or startProcessInstanceByXX - You don’t have to fetch the latest process definition to start a process. You can just pass the processDefinitionKey
    • suspendProcessInstanceById - for suspending processes. What is abort? There is also deleteProcessInstance
    • activateProcessInstanceById - your resume
  • ManagementService- for different management operations
    • Working with suspended jobs, timers, async jobs, dead letter jobs and triggering them
  • RepositoryService - working with the process definitions
  • HistoryService - historic data

There are possibilities for all your functions in 2 services (RuntimeService and ManagementService). The retryProcessInstanceExecution is not really clear. What happens when you have more than 1 async job parallel flow jobs that have failed. Maybe you can retry one, but not the other.

In my opinion the API is quite straightforward and clear. We try to make the methods and services as clear as possible. On top of that all engines follow the same principles and have the same services. However, I am a bit biased :slight_smile:. How long have you worked with the API?

Cheers,
Filip