Hi,
after our previous question in Custom batch job using camunda-batch, it was a lot of work to get our custom batch implementation runnable. We had to write a lot of code on Entity level and so, which was very time consuming and complex. Also a deep knowledge of the batch API was needed.
Furthermore we have a lot more cases where we want to use Camunda Batch, so I had the idea to build a community extension for this. This extension should make it easier to get into using Camunda Batch.
I’ve a lots more ideas like making it possible to provide a Data Collector Class instead of the data itself. Or providing a possibility to automatically trigger the creation of a new batch with a timer job.
I already have a runnable implementation, but not on Github. I will push it in about 2 weeks to Github. (Because of Holiday) But I already want to promote it.
So is there anybody who wants to sponsor me to get it an official extension?
Here are some example how to use the extension:
Creating the Batch itself
In the minimum setting (with default batch values and configuration from Context)
final Batch batch = CustomBatchBuilder.of(data) #List of Objects which should be processed
.jobHandler(testCustomBatchJobHandler)
.create();
or with more Configuration:
final Batch batch = CustomBatchBuilder.of(data)
.configuration(configuration)
.jobHandler(testCustomBatchJobHandler)
.jobsPerSeed(10)
.invocationsPerBatchJob(5)
.create(configuration.getCommandExecutorTxRequired());
The builder takes care about:
- Creating the Batch (Entity)
- Creating the Seed and Monitor Job
- Saves the BatchConfiguration data, no matter of the data type
- Saves you from handling with ConfigurationBytes
The JobHandler
I also created an abstract job handler which you just have to extend and write your Business Logic.
The Abstract Job Handler takes care about:
- Creating Jobs + saving Configuration to ByteArray Table
- Reading data from ByteArray Table for each Batch Jobs
- Cleanup of Jobs + Configuration
In the end, with the abstract class, my job handler looks like:
public class TestCustomBatchJobHandler extends CustomBatchJobHandler<String> {
@Override
public void execute(List<String> data, CommandContext commandContext) {
logger.debug("Work on data", data);
}
@Override
public String getType() {
return "test-type";
}
}
Best regards,
Patrick