Clean Decision Instances

Hi

As part of house keep job , i want to clear the Decision Instances .
I am able clear process instance , however could not find suitable java API to clean Decision instances.
please suggest.

Regards
Prabhu

Hi @pvalluri,

Delete decision instances from the history should do what you want: https://docs.camunda.org/manual/7.12/reference/rest/history/decision-instance/post-delete/

Hope this helps, Ingo

Thanks for the reply…

I want to do that via program.
i,e., wanted to write a java class and call that as time based event to clear the decision instances, part of house keeping job.
please suggest suitable java API to clear the decision instances.

Regards
Prabhu

eg:
after querying the repository for decision definition, want query decision definition and delete …

List<DecisionDefinition> decisionDefinitions = processEngine
  .getRepositoryService()
  .createDecisionDefinitionQuery()
  .decisionDefinitionKey("decisionDefinitionKey")
  .list();
Correction 
eg:
after querying the repository for decision definition, want query for decision instance and delete …

List<DecisionDefinition> decisionDefinitions = processEngine
  .getRepositoryService()
  .createDecisionDefinitionQuery()
  .decisionDefinitionKey("decisionDefinitionKey")
  .list()

@pvalluri if my understanding is correct that you’re expecting history clean up job configuration for decision instances also like process instance history cleanup provided by camunda.

Hi

Thanks for the reply…

I am clearing the processing instances using below code.

List definitions = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey(“servicedesk”)
.orderByProcessDefinitionVersion().desc()
.list();
//for (ProcessDefinition processDefinition : processDefinitions) {
for (int i = 0; i < definitions.size(); i++) {
ProcessInstanceQuery instanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(definitions.get(i).getId());
runtimeService.deleteProcessInstancesAsync(instanceQuery, “completed”);

Similarly , i want to clear process instances as well. pls suggest.

if my approach is incorrect to clean up process instances or decision instances. please advise the right one…
if any other clean procedure available in camunda. let me know.

Regards
Prabhu

correction…
Similarly , i want to clear decision instances as well

For process instance cleanup you can configure like this discussion in the below post:

For decision instances, there’s no history cleanup api available.

So for decision instances we might have to clean programmatically.

Thanks for the reply…

Is there any java API that I can use to clean the decision instances ?

Regards
Prabhu

Here’s the java api for deleting historic process instances.

HistoryService historyService = execution.getProcessEngineServices()
          .getHistoryService();

List<HistoricDecisionInstance> decisionDefinitions = historyService.createHistoricDecisionInstanceQuery()
          .decisionDefinitionKey("decisionDefinitionKey").list();

 decisionDefinitions.stream().map(HistoricDecisionInstance::getId).forEach(
          historicDecisionInstanceId -> historyService
              .deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstanceId));

Thank you…