Bulk insert camunda batch extension

Hi,

I’m using a camunda batch extension to load multiple task, already have configured the
jobsPerSeed=10 and invocationsPerBatchJob=1 to execute the batch, when the batch is executed for example for a size of 20 I can see in the table ACT_RU_TASK 20 records and 20 inserts was executed on the database, after that I changed the configuration to jobsPerSeed=10 and invocationsPerBatchJob=2, when the batch is executed I see in the table ACT_RU_TASK half of the records like 10, when I expected to see the same number of records “20” but with 10 bulk inserts executed on the database.

I don’t know if I am misunderstanding the configuration of these two parameters, but is it posible that camunda batch extension can create this bulk inserts?

Then I will show you the code that I am implementing:

Method which execute the batch in Spring Boot Application

@EventListener
public void afterEngineStarted(PostDeployEvent event) {
		logger.info("Create new Batch");
		final List<String> simpleStringList = IntStream.range(0, 20)
				.mapToObj(i -> "SomeRandomBatchData_" + UUID.randomUUID()).collect(toList());

		CustomBatchBuilder.of(simpleStringList).configuration(event.getProcessEngine().getProcessEngineConfiguration())
				.jobHandler(printStringBatchJobHandler).create();
	}

This is the PrintStringBatchJobHandler implementation

@Autowired
private RuntimeService runtimeService;

@Override
public void execute(List<String> data, CommandContext commandContext) {
	logger.info("Work on data: {}", data.get(0));
	runtimeService.startProcessInstanceByKey("loanApproval");
}

This is the application.yaml configuration

camunda:
  bpm:
    application:
      isDeleteUponUndeploy: false
      isScanForProcessDefinitions: false
      isDeployChangedOnly: true
      isResumePreviousVersions: true
      resumePreviousBy: a value
    job-execution:
      enabled: true
      core-pool-size: 10
      max-jobs-per-acquisition: 10
      deployment-aware: true
    metrics:
      enabled: false
      db-reporter-activate: false
    generic-properties:
      properties:
        batchJobsPerSeed: 10
        invocationsPerBatchJob: 2
    database:
      type: postgres
      schema-update: true
      jdbc-batch-processing: true
    history-level: full

I’m using Camunda 7.14 and Camunda batch extension 1.5.1

I hope you can help with this trouble

Thank you in advance

Juan.

1 Like

Hi Juan,

the problem is simply that the job handler is not correct.

invocationsPerBatchJob = 2 means that you will get passed in a List with two entries, so you have to adjust your job handler e.g. like this:

@Override
public void execute(List<String> data, CommandContext commandContext) {
	logger.info("Work on data: {}", data);
	data.foreach(entry -> runtimeService.startProcessInstanceByKey("loanApproval"));
}

Cheers,
Patrick

Hi @patrick.schalk,

It works fine with your solution!

Thank you very much!

Juan.