Provide a custom history backend
In order to understand how to provide a custom history backend, it is useful to first look at a more detailed view of the history architecture:
- Provide a custom implementation of the HistoryEventHandler interface.
- Wire the custom implementation in the process engine configuration.
Composite History HandlingNote that if you provide a custom implementation of the HistoryEventHandler and wire it to the process engine, you override the default DbHistoryEventHandler. The consequence is that the process engine will stop writing to the history database and you will not be able to use the history service for querying the audit log. If you do not want to replace the default behavior but only provide an additional event handler, you can use the class
org.camunda.bpm.engine.impl.history.handler.CompositeHistoryEventHandler that dispatches events to a collection of handlers.Spring BootNote that providing your custom
HistoryEventHandler in a Spring Boot Starter environment works slightly differently. By default, the ASEE Flow Spring Boot starter uses a CompositeHistoryEventHandler which wraps a list of HistoryEventHandler implementations that you can provide via the customHistoryEventHandlers engine configuration property. If you want to override the default DbHistoryEventHandler, you have to explicitly set the enableDefaultDbHistoryEventHandler engine configuration property to false.Implement a custom history level
To provide a custom history level the interfaceorg.camunda.bpm.engine.impl.history.HistoryLevel has to be implemented. The custom history level implementation
then has to be added to the process engine configuration, either by configuration or a process engine plugin.
org.camunda.bpm.engine.impl.history.event.HistoryEventTypes (see Javadocs).
The second argument is the entity for which the event is triggered, e.g., a process instance, activity
instance or variable instance. If the entity is null the engine tests if the history level in general
handles such history events. If the method returns false, the engine will not generate
any history events of this type again. This means that if your history level only wants to generate the history
event for some instances of an event it must still return true if entity is null.
Please have a look at this complete example to get a better overview.
Removal time inheritance
Historic instances inherit the removal time from the respective historic top-level instance. If the custom history level is configured in a way, so that the historic top-level instance is not written, the removal time is not available. The following historic instances are considered as top-level instances:- Batch instance
- Root process instance
- Root decision instance