Custom History Level

I’m trying to prevent certain variables from being stored in the history tables as the values are quite big and there is no requirements to store them.

However I’m unable to activate my custom history level class. I’m using Spring Boot and extending AbstractProcessEnginePlugin and registering my class that implements HistoryLevel applying logic for isHistoryEventProduced. I’ve tried debugging the call but it never reaches my method even though I can see the level being registered by the engine. Is there anything else I need to do? I’ve also tried registering a ExecutionListener and tried removing the variable from the execution context but the history still gets invoked.

Any help on this would be appreciated.

Implement this: https://github.com/camunda/camunda-bpm-spring-boot-starter/blob/master/extension/starter/src/main/java/org/camunda/bpm/spring/boot/starter/configuration/CamundaHistoryConfiguration.java

Then your bean will be used instead of https://github.com/camunda/camunda-bpm-spring-boot-starter/blob/master/extension/starter/src/main/java/org/camunda/bpm/spring/boot/starter/configuration/impl/DefaultHistoryConfiguration.java

If you extend just the Abstract-Plugin, history will be applied twice …

Does this mean I have to provide my own implementation of HistoryEventProducer?

I think there are some instructions on how to use this in the documentation as well as the code examples referenced above. In the documentation, they reference two examples of “custom” history implementations, one of which is only recording history for specific processes and the other I can’t remember. You can find some information about it here: https://docs.camunda.org/manual/latest/user-guide/process-engine/history/

We built a completely separate custom history service because the one in Camunda is very “expensive” in terms of database overhead.

@jangalinski I have tried something like this: https://github.com/hedza06/camunda-mongodb-history-stream and place breakpoint in CustomHistoryEventHandler.java at line 29 but code execution never enters.

Any hints?
Thank you in advance.

In CustomProcessEnginePlugin.java,

processEngineConfiguration.setHistoryEventHandler(
     new CompositeDbHistoryEventHandler(CustomHistoryEventHandler.getInstance())
);

once I moved this to postInit() things started working as expected.

1 Like

You’re right! Thank you @jgigliotti :slight_smile: