The datasource is defined in the standalone.xml (assuming you are using a standalone WildFly instance versus a multi-instance domain configuration) “” section. You can switch between an external DBMS (e.g. PostgreSQL) and the default H2 database, but I can’t think of an easy way for you to use both simultaneously unless you were using multiple Camunda BPMN engines, which I have never done. We use a single database with a single Camunda instance.
One way to achieve this is to install two instances of WildFly/Camunda on the same server. The first instance can be your production instance and it would use the PostgreSQL database. The second instance would be “offset” to another set of TCP ports and use the H2 database.
To offset the second WildFly/Camunda instance, create a completely separate installation on the server. In the standalone.xml file, find the following entry:
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
The last attribute is the integer value offset of all (or most) TCP ports for the second instance. For example, we run multiple instances on the same server and I offset them 1000 ports. This is an example of how that would look:
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:1000}">
When selecting the TCP ports to use, be sure they won’t conflict with other services.
If you wanted to do what I describe above, do the following:
-
Download the Camunda 7.X/WildFly 10.1 distribution from the Camunda site
-
Create a directory on the server for the first instance (e.g. /usr/local/camunda) and untar the entire distribution into it.
-
Create a second directory on the server for the second instance (e.g. /usr/local/camunda_1000) and untar the entire distribution into it.
-
Install the PostgreSQL database
-
From the root of the installation (e.g. /usr/local/camunda/camunda-bpm-ee-wildfly10-7.6.2-ee), find the “sql/create” directory. In there you see two scripts for creating the PostgreSQL database that you need to run. For example, run “postgres_engine_7.6.2-ee.sql” first, and then run “postgres_identity_7.6.2-ee.sql”. This will set up the Camunda database. Note, I’m not sure, but Camunda might even do this for you automatically if you create an empty database and user.
-
Create a user and password to the Camunda database and grant DELETE, INSERT, SELECT, and UPDATE privileges to the user.
-
In the first instance directory, open the standalone.xml file and find the the datasource section. You will need to modify the “datasource” to match what is required for PostgreSQL. I can’t help you with specifics as we don’t use PostgreSQL, but here is an example for MySQL:
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jta="true" jndi-name="java:jboss/datasources/ProcessEngine" pool-name="ProcessEngine" enabled="true" use-java-context="true" use-ccm="true" statistics-enabled="true">
<connection-url>jdbc:mysql://localhost:3306/camunda?autoReconnect=true&useSSL=false</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql</driver>
<pool>
<min-pool-size>10</min-pool-size>
<initial-pool-size>10</initial-pool-size>
<max-pool-size>200</max-pool-size>
</pool>
<security>
<user-name>camunda</user-name>
<password>CamuPass1</password>
</security>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>0</query-timeout>
<use-try-lock>0</use-try-lock>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>0</allocation-retry-wait-millis>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>
</drivers>
</datasources>
</subsystem>
-
For the second instance, you need only modify the “offset” described above as the H2 database is already configured by default.
There may be additional configuration steps as described in the Camunda documentation on WildFly, but at this point you should be able to start both instances.
If you need to install a driver, which you probably will, then you might want to have a look at this page: http://ralph.soika.com/wildfly-install-postgresql-jdbc-driver-as-a-module/
There are countless examples of how to set up the driver, but if you look at the example datasource section I provided, it will give you general guidelines.
Finally, you don’t really need to write Java database connections for Camunda to work. It already has everything it needs. This page gives details on how to connect to a PostgreSQL database with Java: https://jdbc.postgresql.org/documentation/80/connect.html. There are huge number of examples of how to do this, but I’ve never done it as I work exclusively in MySQL.
I hope this gets you started. Let me know if you have any questions.
Michael