cancel
Showing results for 
Search instead for 
Did you mean: 

Proposal: a new API to end a process

f_lombardo
Champ in-the-making
Champ in-the-making
Hi all,

what do you think about creating a new API to end a process? Will it have some drawbacks?

Thanks.

Bye


Franco
12 REPLIES 12

frederikherema1
Star Contributor
Star Contributor
"Ending" a process externally is not really BPMN-compliant, if it's not modeled in explicitly () Smiley Wink However, we have a method on the runtime service which terminates an existing process. The process will just stop, only any "execution-listeners" -which are defined on "event=end" of the process- will be called:


/** Delete an existing runtime process instance.
   * @param processInstanceId id of process instance to delete, cannot be null.
   * @param deleteReason reason for deleting, can be null.
   * @throws ActivitiObjectNotFoundException when no process instance is found with the given id.
   */
  void deleteProcessInstance(String processInstanceId, String deleteReason);
   

f_lombardo
Champ in-the-making
Champ in-the-making
Does this method "clean up" the history of the process?

Thanks.

Bye

Franco

frederikherema1
Star Contributor
Star Contributor
It does not, you're required to delete the HistoricProcessInstance using the HistoroService, AFTER you deleted the runtime one.

f_lombardo
Champ in-the-making
Champ in-the-making
Uhm… IMHO it sounds a bit confusing: I have to delete a process in order to end it, while the "delete" API doesn't delete it completely…

Anyway I'll try.

Thanks a lot.

Bye

Franco

jbarrez
Star Contributor
Star Contributor
The reason for this is that some companies want to keep an audit trail of the history, even when things are deleted.

frederikherema1
Star Contributor
Star Contributor
The same concept as completing a process is applied, once completed it doen't exist anymore in the runtime. History is kept for audit-trail as Joram said.

dimitrihautot
Champ in-the-making
Champ in-the-making
Hello,

For my business case, I need to be able to delete active (i.e. not completed) process instances.
However, for selected users, these deleted instances should be visible.

I am already using the API suggested method
void deleteProcessInstance(String processInstanceId, String deleteReason);for that purpose.

However, I don't see a way to query the (Historic)ProcessInstanceQuery interfaces to include these deleted instances: methods "finished()" and "unfinished()" seem to only take into account the "complete" status of a process instance. Am I wrong?

Thanks!

jbarrez
Star Contributor
Star Contributor
these deleted instances: methods "finished()" and "unfinished()" seem to only take into account the "complete" status of a process instance. Am I wrong?

Indeed that is correct.

When you query the historic process instance by id, don't they just show up in the query results?

frederikherema1
Star Contributor
Star Contributor
Perhaps we need a similar query-possibility as we have for HistoricTasks:


/** Only select historic task instances with the given task delete reason. */
  HistoricTaskInstanceQuery taskDeleteReason(String taskDeleteReason);

When deleting a process, a reason can be passed. If we allow for HistoricProcessInstances to be queries on that, you can differentiate between those processes. A current workaround is maybe to inspect the "end-activity" to see if it has reached the actual end-event or not…