What is the Relations between the tables where we are storing camunda meta data

Hi @Ingo_Richtsmeier ,

Thank you for providing the above info . It worked after setting the TTL for existing process definitions. It is setting the removal time automatically once they are finished. Using the Rest API, I can able to set the removal time for completed process instances.

Can you also help me on setting the TTL for Batches , Job Logs , Metrics, Case Instances and Decision Instances. what is the time period we need to use for deleting these one’s.

  • Process Instances: Base time is either the time when the process instance starts or the time at which it finishes. This is configurable.

Configured as end + TTL(18 months) as per the business requirement.

  • Decision Instances: Base time is the time when the decision is evaluated.
  • Case Instances: The removal time concept is not implemented for case instances.
  • Batches: Base time is either the time when the batch is created or when the batch is completed. This is configurable.

Can you please suggest me what is the time period we need to configure to delete Decision Instances, case instances and Batches.

Appreciate your help in advance.

Regards,
Thanuja.

Hi @Thanuja_Vadlamudi,

here you can find the configuration parameters for all entities that can be cleaned up: History and Audit Event Log | docs.camunda.org.

Decisions and cases are handled in the same way as processes and my further comment here applies to them.

The time to live for job log, batches and metrics has to be filled in the engine configuration (i.e. application.yml in case of Spring Boot and Camunda Run).

Hope this help, Ingo

Hi Ingo,

There is no parameter historyCleanupJobLogTimeToLive in our config file. is there any similar property which cleanup history Cleanup Job Logs.

Regards,
Thanuja.

Hi Ingo,

Kindly help me here. the removal time of all instances is always equal to the removal time of the root instance. Kindly let me know how this can be achieved. In my case, I had set the TTL for root process Definition and child process Definition. Hence It is setting the removal time different than root instnace.

Kindly help me here.

Regards,
Thanuja.

Hi @Thanuja_Vadlamudi,

I didn’t get all the details from your question.

Could you please elaborate:

  • Which removal strategy did you configure?
  • How? Maybe you post the current configuration here.
  • Are any Removal_time_ values left blank in the database?

Cheers, Ingo

Hi Ingo,

Thanks for the Reply.

I had configured Removal-Time-based Strategy in the config file as below.

config.setHistoryTimeToLive(“P548D”);
config.setHistoryCleanupBatchWindowStartTime(“19:30”);
config.setHistoryCleanupBatchWindowEndTime(“22:30”);
config.setHistoryCleanupStrategy(ProcessEngineConfiguration.HISTORY_CLEANUP_STRATEGY_REMOVAL_TIME_BASED);
config.setHistoryRemovalTimeStrategy(ProcessEngineConfiguration.HISTORY_REMOVAL_TIME_STRATEGY_END);
config.setHistoryCleanupBatchSize(500);

using the below method, I had set the TTL for Root Process and Child process Definitions.
processEngine.getRepositoryService().updateProcessDefinitionHistoryTimeToLive(processDefinitionId, 5);

SeoSfdcBusinessOrder invokes SeoSfdcInitiatedAsriTransaction. SeoSfdcInitiatedAsriTransaction invokes SeoSfdcInitiatedAsriComponent.

SeoSfdcBusinessOrder:2:523028147
|
SeoSfdcInitiatedAsriTransaction:4:491490864
|
SeoSfdcInitiatedAsriComponent:2:367225788

It is setting Removal_time_ as Root process end time + TTL for the Root. Child - Child Process end time + TTL. It is setting differently for root and child. It should be consistent for root and its instances.

Regards,
Thanuja.

Regards,
Thanuja.

Hi Ingo,

Kindly help me in resolving the above issue.

Regards,
Thanuja.

Hi Ingo,

Root Process Instance ID is not set correctly for the process instances. For Example 154511894 - Root Process ID triggers 154512959 Process. 154512959 Process triggers 154513398 process.

154511894 → 154512959 → 154513398 .

In this case, 154512959 and 154513398 should have the root process instance 154511894 right? In our case It is setting the same process instance as root process instance.

Could you help me how it will set the root process instance. Below is the code to start the new process from another process.

camundaApi.startProcessInstanceByKey(Enums.Domain.swift, “SeoSfdcInitiatedAsriTransaction”, seoBusinessKey, variables);

processOperations.create(new ProcessInstanceRequest()
.domain(domain.toString())
.modelName(processDefinitionKey)
.businessKey(seoBusinessKey)
.variables(variables));

Regards,
Thanuja.

Hi @Thanuja_Vadlamudi,

if you start the process instance with an API call like you did, they are always independent process instances. They will always differ if the Root process instance ID.

The Root process instance ID is only available with Call activities.

To keep the connection of your processes, you may use the business key or a special process variable.

I’ve double checked the removal_time_ behavior with this example: https://github.com/camunda/camunda-bpm-examples/tree/master/spring-boot-starter/example-invoice. It behaves like documented here: History and Audit Event Log | docs.camunda.org.

The removal time of the subprocess is set only when the super process is ended. Both instances get the same removal time value.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier ,

we used business key to connect those processes. Is there any way to cleanup the hierarchy at the same time for the independent processes.

Or should I change the the code to invoke the process using Call Activity ? In this case I need to update the root process instance id for all the existing process.

Kindly let me know which is flexible and recommended process.

Regards,
Thanuja.

Hi @Thanuja_Vadlamudi,

it depends on your use case if you should change your loosely coupled processes into thightly coupled processes with call activity, just to get the removal time set to the same dateTime.

It seems too technical to me as a good reason for changing the process design.

Is it really this important, that all processes get removed from the history at the same time?

Another option could be an end listener on the last process, that sets the removal time to a specific date.

This could be an example:

public class SetRemovalTimeListener implements ExecutionListener {

  @Override
  public void notify(DelegateExecution execution) throws Exception {
    Date removalTime = null;
    String historicProcessInstanceIds = null;
    execution.getProcessEngineServices()
     .getHistoryService().setRemovalTimeToHistoricProcessInstances()
     .absoluteRemovalTime(removalTime).byIds(historicProcessInstanceIds).executeAsync();
  }
}

Hope this helps, Ingo

1 Like

Hi Ingo,

I had created end listener on the last process as below.


Kindly correct me if it is not set correctly.

Regards,
Thanuja.

Hi @Thanuja_Vadlamudi,

looks good to me. Did you get the desired values in the database?

If yes, everything is fine.

If not, please provide the implementation of the Java class.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier ,

I am getting the below error.

‘com.centurylink.wf.process.camunda.purge.SetRemovalTimeListener’: Field definition uses unexisting field ‘businessOrderProcessInstanceId’ on class com.centurylink.wf.process.camunda.purge.SetRemovalTimeListener: field is null

I had set the below values in the last process.
pec.setVariable(“removalTime”, statusDate.toString());
pec.setVariable(“businessOrderProcessInstanceId”, businessOrderProcessInstanceId.apply(pec));

I am getting those values and injecting them into the end listener as below.


Kindly help me to resolve this issue.

Regards,
Thanuja.

Hi @Thanuja_Vadlamudi,

could you please share the complete code of the listener class? Otherwise it’s hard fro to guess what’s going wrong here.

Cheers, Ingo

Hi @Ingo_Richtsmeier ,

Kindly find the below code.

  1. SetBusinessOrderStatus Process:
    pec.setVariable(“removalTime”, statusDate.toString());
    pec.setVariable(“businessOrderProcessInstanceId”,businessOrderProcessInstanceId.apply(pec));

  2. Configured end listener on the last process.

3.SetRemovalTimeListener:-
public class SetRemovalTimeListener implements ExecutionListener {
private static final Logger LOGGER = LoggerFactory.getLogger(CamundaProcessOperations.class);

@Autowired
private ProcessOperations processOperations;
private static final int TIME_TO_LEAVE_IN_MONTHS = 18;

@Override
public void notify(DelegateExecution execution) throws Exception {

	String completedTime = (String) execution.getVariable("removalTime");
	LOGGER.info(
			" Completed Time for the BOID : "+ completedTime);
    LocalDate date = LocalDate.parse(completedTime);
    LocalDate removalTime = date.plusMonths(TIME_TO_LEAVE_IN_MONTHS);
    ZoneId defaultZoneId = ZoneId.systemDefault();
	Date removalDate = Date.from(removalTime.atStartOfDay(defaultZoneId).toInstant());
    
    String rootProcessInstanceId = (String) 
    execution.getVariable("businessOrderProcessInstanceId");
    
	List<String> processInstanceIds = 
    processOperations.getProcessInstancesOfRoot(rootProcessInstanceId);
	if(processInstanceIds != null && !processInstanceIds.isEmpty())
    	execution.getProcessEngineServices().getHistoryService().setRemovalTimeToHistoricProcessInstances().absoluteRemovalTime(removalDate).byIds(processInstanceIds.toString()).executeAsync();
    else {
    	//TODO : add logger for empty processInstanceIds
    }
  }

}

Regards,
Thanuja.

Hi @Thanuja_Vadlamudi,

from the first galnce you could remove the fields from the listener configuartion in the modeler, as you don’t use them in the code.

Fields are a seldom used concept to provide details for a generic implementation of listeners and java delegates: Delegation Code | docs.camunda.org

Hope this helps, Ingo

Hi @Ingo_Richtsmeier ,

I am using the removalTime, businessOrderProcessInstanceId variables in the end listener class which are set in the last process(SetBusinessOrderStatus Process). If I remove them in the modeler, Can I access those variables using execution.getVariable(“removalTime”)?

Regards,
Thanuja.

Hi @Thanuja_Vadlamudi,

Yes, thats the way to access process variables. They are resolved at runtime and there is no need to specifiy them in the process model.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier,

Could you also let me know which one is the right call to get the list of process instances which are having variableValueLike(“parentProcessInstanceId”, value)

runtimeService.createProcessInstanceQuery().matchVariableNamesIgnoreCase().variableValueLike(“parentProcessInstanceId”, rootProcessID).list();

runtimeService.createVariableInstanceQuery().matchVariableNamesIgnoreCase().variableValueLike(“parentProcessInstanceId”, rootProcessID).list();

Regards,
Thanuja.