Using different datasources for Camunda schema and additional application data in Embedded Springboot project

How can we use two datasources in a Springboot project where one datasource will contain camunda schemas and the other will be used for additional application data that are out of scope of Camunda.

From default configuration of Application.yml, spring uses below properties to create and/or use Camunda schemas.

spring:
datasource:
url: …
username: …
password: …
driverClassname: …

Now suppose, I want to create two different datasources, namely, camundaData and applicationData inside my embedded springboot application. The updated yml should look like below -

spring:
datasource:
camundaData:
url: …
username: …
password: …
driverClassName: …
applicationData:
url: …
username: …
password: …
driverClassName: …

Now I can create necessary datasource bean and jdbcTemplate bean for applicationData to have it used by DAO classes inside, to create, store and access application data. But what is the exact way to pass on the information to Spring to use the other datasource, i.e., camundaData for creating and accessing Camunda related data. Is there any specific property that needs to be provided in application.yml to set a specific datasource as camunda datasource among a collection of multiple datasources.

1 Like

Ehm… I posted a link to a solution and two days later I have to implement this myself and run into problems. I want to define two datasources and two tx-managers. They should be equals, i.e. none of them should be marked as “primary” – since I wire everything myself. But camunda seems to require that a datasource and a tx-manager still be marked as primary. What’s even worse: These are NOT the objects that are eventually used by the camunda engine!

I think this is because here a reference is still required.

Has anybody solved this? How?