5 Configuration Guide - Reference Documentation
Authors: Martin Schimak
Version: 0.5.0
Table of Contents
5 Configuration Guide
It is not necessary to add configuration in order to get started. However, you will need some configuration to deploy to other environments than development and test. The plugin provides the possibility to adapt to your specific requirements by adding a new section 'camunda' to your Config.groovy (either top-level or beneath a specific environment):camunda { … }
You will need such a configuration section to deploy to other environments than development and test. Find out more in the following two chapters.
5.1 Set the deployment scenario
You can set the deployment scenario for your process engine. The plugin currently supports the deployment scenarios- 'embedded' the process engine is embedded into your grails application and started and stopped with your grails application lifecycle
- 'shared': the process engine is shared, so preconfigured within and managed by your container
- 'none': the process engine configuration and startup is turned off
camunda { deployment.scenario = "embedded" // (or "shared", "none") }
As long as you do not set this value explicitely, the plugin assumes for grails' environmentsThe moment you set the value explicitely, the plugin won't interfere with your decision. However,dev
andtest
the value 'embedded' to be the default scenario, *for all other environment the value 'shared'* (except if you have provided explicitcamunda.engine.configuration
values for an embedded engine in which case 'embedded' remains default for other environments, too). The moment you set this value explicitely, the plugin of course won't interfere anymore!
Typically, you will want to use the 'shared' engine only for those grails environments which you use to prepare your container deployment war, e.g. 'production':Currently the plugin only supports tomcat as a container to look up a shared process engine. Download camunda BPM Tomcat distribution.environments { production { camunda { deployment { scenario = "shared" } } } }
null
5.2 Configure an 'embedded' process engine
5.2.1 Configure your process engine
You can fully control your embedded camunda process engine configuration via Config.groovy:camunda { engine { configuration { … } } }
- your database is populated with camunda tables the first time the database is accessed
- any .bpmn (and for legacy reasons .bpmn20.xml) process definitions found in the classpath will be deployed to the database
- the job executor is turned on
This choice was made in order to make it as easy as possible to get started while relying on explicit configuration choices when deploying to other (and potentially production) databases.That means if you want to have that same behaviour for any other environment, you need to explicitely configure that in Config.groovy:
camunda { engine { configuration { databaseSchemaUpdate = true deploymentResources = ['classpath:/**/*.bpmn', 'classpath:/**/*.bpmn20.xml'] jobExecutorActivate = true } } }
camunda { engine { configuration { databaseSchemaUpdate = false deploymentResources = [] jobExecutorActivate = false } } }
Please be aware that during integration test phase of any environment, two camunda configuration values are set by the plugin: the camunda job executor is turned off and service mocking is made available. Find more information about that in section testing.
5.2.2 Use primitive types, beans or any other object
For configuration, you can of course use primitive typed configuration values such as Strings and booleans, like e.g.camunda { engine { configuration { processEngineName = "myCustomName" databaseSchemaUpdate = false } } }
List<BpmnParseListener> parseHandlers = new ArrayList<BpmnParseListener>(); parseHandlers.add(new CustomParseHandler());camunda { engine { configuration { preParseListeners = parseHandlers } } }
camunda {
engine {
configuration {
dataSource = "dataSource_camunda"
}
}
}
5.2.3 Use an alternative database
camunda's ORM mapping is provided by the mybatis mapping framework. Therefore the plugin can - and does by default - reuse your Grails 'dataSource' and 'transactionManager' beans, however it needs to be informed about a databaseType different from Grails default 'h2':camunda {
engine {
configuration {
databaseType = "postgres" // one of (as of writing): [h2, mysql, oracle, postgres, mssql, db2]
}
}
}
dataSource { dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', '' url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" } … dataSource_camunda { dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', '' url = "jdbc:h2:mem:devDbCamunda;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" }
camunda {
engine {
configuration {
dataSource = "dataSource_camunda"
}
}
}
5.3 Configure a 'shared' process engine
5.3.1 Provide a custom processes.xml file
When deploying to a 'shared' process engine container, camunda Grails Plugin will automatically add an emptyMETA-INF/processes.xml
to your war
file, in case you
do not provide your own.Please read about camunda's processes.xml to learn more about its configuration possibilities.If you want to provide your custom
processes.xml
, just place it into your grails-app/processes
folder like/grails-app/processes/META-INF/processes.xml
5.3.2 Provide a custom process application class
camunda Grails Plugin will automatically take care of registering a default process application class of typeorg.camunda.bpm.engine.spring.application.SpringServletProcessApplication
for you. So normally you don't need to do anything.However, for some reason, you may want to provide a custom process application class. Place this class
inside your grails application's /src/groovy
or src/java
folder and register it likeenvironments {
production {
camunda {
deployment {
scenario = "shared"
application = my.project.pkg.MyCustomSpringServletProcessApplication
}
}
}
}
org.camunda.bpm.engine.spring.application.SpringServletProcessApplication
)
or for all other types the plugin will register nothing and assume that you want your container to detect and
use that class. In that latter case don't forget to annotate it with org.camunda.bpm.application.ProcessApplication
.
5.3.3 Configure and finetune dependencies provided by a camunda BPM container
When needing to prepare a war for a 'shared' process engine scenario, one needs to be aware that- the 'org.camunda.bpm:camunda-engine' dependencies are provided by the container
- the 'org.codehaus.groovy:groovy-all' library is provided by the container
environments {
production {
provided ("org.camunda.bpm:camunda-engine:$camundaVersion") {
excludes 'spring-beans'
}
}
}
camunda.deployment.shared.war.excludes = ['camunda-*.jar', 'groovy-all-*.jar'] camunda.deployment.shared.war.includes = ['camunda-engine-spring-*.jar']
5.4 Consider 'java.util.logging' settings
camunda uses java.util.logging. Therefore you need to make a conscious choice about whether to turn on/off the 'grails.logging.jul.usebridge' setting in your Config.groovy. See the information about the performance impact on http://www.slf4j.org.In case the bridge is not turned off explicitely by you, the plugin will turn it on for all Grails test phases. However, your explicit choice won't be overridden.This decision in particular makes sure that the bridge is turned on for tests executed in the default Grails environment 'test', for which no explicit setting is made in the default grails application. As soon as you make an explicit decision for any of your default or custom environments, the plugin won't interfere anymore.
5.5 Use an alternative version of camunda
Currently the plugin comes bundled with a dependency to the release 7.3.0 of camunda BPM. However you may want to choose another version. You then have to explicitely override the needed dependencies in your BuildConfig.groovy:dependencies { compile ("org.camunda.bpm:camunda-engine:$camundaVersion") { excludes 'spring-beans' } runtime ("org.camunda.bpm:camunda-engine-spring:$camundaVersion") { excludes 'spring-context', 'spring-jdbc', 'spring-orm' } }
repositories {
mavenRepo "https://app.camunda.com/nexus/content/groups/public"
}
5.6 Provide alternative bean names
Many of camunda's API service names are quite generic (like 'taskService', 'managementService' etc) and could easily clash with names you want to use in your application for other purposes - even more so when having in mind the Grails naming convention to use *Service as a name pattern for Grails services. On the other hand typical camunda users are used to the established service names and will expect to use these services via their established names. Therefore the plugin provides these services via the established names. However, in order to avoid potential name conflicts with grails services pre-existing in your project, the plugin also allows to change these default bean names via configuration:camunda { beans.runtimeService = 'myCamundaRuntimeService' }
def myCamundaRuntimeService
5.7 Override plugin configuration with custom beans
Of course, it is also possible to override some or all of the camunda spring beans defined by the plugin via the standard Grails way: by editing 'grails-app/conf/spring/resources.groovy'. In order to do that properly it is useful to know that the plugin registers all beans following the name convention camunda[DefaultAlias]Bean, e.g. the 'processEngine' is registered as bean 'camundaProcessEngineBean', then given either its default alias 'processEngine' (or its custom alias defined by the user).This decision was made partly in order to allow the configuration of alternative bean names, partly because some historic 2.3 versions of Grails display issues with custom spring beans named in potential "conflict" with the *Service name convention for Grails services.
5.8 Configure auto reloading of bpmn process definitions
You can automatically reload and redeploy '.bpmn' process definitions placed beneath 'grails-app/processes'. When changing the process definition while you are running your application with 'run-app', it will be redeployed to the process engine.You can turn this feature on/off explicitely:camunda { deployment.autoreload = true // (or false) }
The autoreload feature is by default enabled for grails 'dev' and 'test' environments. For all other environments it is by default disabled.