Detail on Custom batch

Hello,

I need to set up a batch for my project and we want to use our BPM to do that.

I saw that camunda custom batch extension can do the trick, my only issue is that there is only this link explaining how to use camunda custom batch : https://github.com/camunda/camunda-bpm-custom-batch/tree/master/extension .

But from my point of view some context is missing because i don’t understand how to implements it.

My goal is to create a cronned BPMN process which will have two tasks : ‘collect datas’ and ‘process datas’. My idea was to use the camunda custom batch extension to ‘process datas’, to do so i wanted to link the service task to a class extending ‘CustomBatchJobHandler’ which will process datas using the execute() method.

First question : is this possible ? Because i assume that the batch need to be created before and then once the batch is created , the datas can be processed . But i don’t know when and where to start the batch and when and where to process my datas?

The batch can be created using this :

 final Batch batch = CustomBatchBuilder.of(data) #List of Objects which should be processed
        .jobHandler(printStringBatchJobHandler)
        .create();

And the datas can be processed using this :

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

But i don’t know where to create the batch and when datas should be processed. Thanks.

Finally i got my answer thanks to this git repository : https://github.com/tomconn/camunda-batch-example

Thanks :slight_smile:

1 Like

Hi,

sorry for my late response, if you still have questions, feel free to place it here!

Cheers,
Patrick

Hi ,

Indeed i have one question , i don’t understand what is the use of jobsPerSeed ? it’s seems like to have no effect on my batch . When using invocationsPerBatchJob , suppose i set 5 for a set of 15 datas , then the batch will create 3 jobs processing 5 datas among the 15. So i’m confused with the use of this parameter because i thought it was used to set the number of job to create but it’s seems like it’s not the case. Thanks.

Hi,

jobsPerSeed is important if working on a huge amount of date. In your example it doesn’t matter, because default is 10. Lets assume you have an amount of 500 data entries. When the batch “starts”, the seed job will create 10 job where each job works on 5 data entries. If those jobs are finished, the seed job again starts to create 10 new jobs which are again working on 5 data entires per job. So the seed job will run 10 times, and each time it creates 10 jobs.

So if you have a really huge amount, you could e.g. increase jobsPerSeed to 100. But remember that then also your job executer have a lot of work to do and it could be that e.g. timer jobs are not triggered in time. But there are some possibilities to handle such a case by configuring the job executer:
https://docs.camunda.org/manual/latest/user-guide/process-engine/the-job-executor/#the-job-order-of-job-acquisition

Thanks you very much it’s clear :slight_smile: .