Process Engine Configuration
The auto starter uses the org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin
mechanism to configure the engine.
The configuration is divided into sections. These sections are represented by the marker interfaces:
org.camunda.bpm.spring.boot.starter.configuration.CamundaProcessEngineConfiguration
org.camunda.bpm.spring.boot.starter.configuration.CamundaDatasourceConfiguration
org.camunda.bpm.spring.boot.starter.configuration.CamundaHistoryConfiguration
org.camunda.bpm.spring.boot.starter.configuration.CamundaHistoryLevelAutoHandlingConfiguration
org.camunda.bpm.spring.boot.starter.configuration.CamundaJobConfiguration
org.camunda.bpm.spring.boot.starter.configuration.CamundaDeploymentConfiguration
org.camunda.bpm.spring.boot.starter.configuration.CamundaJpaConfiguration
org.camunda.bpm.spring.boot.starter.configuration.CamundaAuthorizationConfiguration
org.camunda.bpm.spring.boot.starter.configuration.CamundaFailedJobConfiguration
org.camunda.bpm.spring.boot.starter.configuration.CamundaMetricsConfiguration
Default Configurations
The following default and best practice configurations are provided by the starter and can be customized or overridden.
DefaultProcessEngineConfiguration
Sets the process engine name and automatically adds all ProcessEnginePlugin
beans to the configuration.
DefaultDatasourceConfiguration
Applies the datasource and transaction management configurations to the process engine.
If you want to configure more than one datasource and don’t want to use the
@Primary
one for the process engine, then name the one you want to use as camundaBpmDataSource
.
@Bean
@Primary
@ConfigurationProperties(prefix="datasource.primary")
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name="camundaBpmDataSource")
@ConfigurationProperties(prefix="datasource.secondary")
public DataSource secondaryDataSource() {
return DataSourceBuilder.create().build();
}
DefaultHistoryConfiguration
Applies the history configuration to the process engine. If not configured, the history level FULL is used.
If you want to use a custom HistoryEventHandler
, you just have to provide a bean implementing the interface.
@Bean
public HistoryEventHandler customHistoryEventHandler() {
return new CustomHistoryEventHanlder();
}
DefaultHistoryLevelAutoHandlingConfiguration
As camunda version >= 7.4 supports history-level auto
, this configuration adds support for versions <= 7.3.
To have more control over the handling, you can provide your own
org.camunda.bpm.spring.boot.starter.jdbc.HistoryLevelDeterminator
with namehistoryLevelDeterminator
IMPORTANT: The default configuration is applied after all other default configurations using the ordering mechanism.
DefaultJobConfiguration
Applies the job execution properties to the process engine.
To have more control over the execution itself, you can provide your own
org.camunda.bpm.engine.impl.jobexecutor.JobExecutor
org.springframework.core.task.TaskExecutor
namedcamundaTaskExecutor
beans.
IMPORTANT: The job executor is not enabled in the configuration.
This is done after the spring context successfully loaded (see org.camunda.bpm.spring.boot.starter.runlistener
).
DefaultDeploymentConfiguration
If auto deployment is enabled (this is the case by default), all processes found in the classpath are deployed. The resource pattern can be changed using properties (see properties).
DefaultJpaConfiguration
If JPA is enabled and a entityManagerFactory
bean is configured, the process engine is enabled to use JPA (see properties).
DefaultAuthorizationConfiguration
Applies the authorization configuration to the process engine. If not configured, the camunda
default values are used (see properties).
Overriding the Default Configuration
Provide a bean implementing one of the marker interfaces. For example to customize the datasource configuration:
@Configuration
public class MyCamundaConfiguration {
@Bean
public static CamundaDatasourceConfiguration camundaDatasourceConfiguration() {
return new MyCamundaDatasourceConfiguration();
}
}
Adding Additional Configurations
You just have to provide one or more beans implementing the org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin
interface
(or extend from org.camunda.bpm.spring.boot.starter.configuration.impl.AbstractCamundaConfiguration
).
The configurations are applied ordered using the spring ordering mechanism (@Order
annotation and Ordered
interface).
So if you want your configuration to be applied before the default configurations, add a @Order(Ordering.DEFAULT_ORDER - 1)
annotation to your class.
If you want your configuration to be applied after the default configurations, add a @Order(Ordering.DEFAULT_ORDER + 1)
annotation to your class.
@Configuration
public class MyCamundaConfiguration {
@Bean
@Order(Ordering.DEFAULT_ORDER + 1)
public static ProcessEnginePlugin myCustomConfiguration() {
return new MyCustomConfiguration();
}
}
Or, if you have component scan enabled:
@Component
@Order(Ordering.DEFAULT_ORDER + 1)
public class MyCustomConfiguration implements ProcessEnginePlugin {
@Override
public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
//...
}
...
}
or
@Component
@Order(Ordering.DEFAULT_ORDER + 1)
public class MyCustomConfiguration extends AbstractCamundaConfiguration {
@Override
public void preInit(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
//...
}
...
}