Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-12114

Spring Boot Starter incorrectly works with multiple databases

    • Icon: Bug Report Bug Report
    • Resolution: Duplicate
    • Icon: L3 - Default L3 - Default
    • None
    • None
    • spring-boot
    • None

      We're using Camunda BPM with Spring Boot with the following configuration:

      • our primary DataSource bean is our application database
      • we have a non-primary bean camundaBpmDataSource which is the datasource that Camunda should use

      This configuration creates a problem with the DefaultDatasourceConfiguration in the Spring Boot Starter. While the starter expects that Camunda's datasource can be non-default (so camundaBpmDataSource overrides the primary datasource), it uses the default PlatformTransactionManager, which is the transaction manager for the primary datasource.

      As a result, Camunda creates a lot of connections to the primary datasource which it doesn't actually use.

      We've fixed this for ourselves by providing a fixed version of CamundaDatasourceConfiguration, but it would be great if this could be somehow fixed in the starter itself.

        This is the controller panel for Smart Panels app

            [CAM-12114] Spring Boot Starter incorrectly works with multiple databases

            Hi m_burst,

            Thank you for reaching out to us with this.

            Could you please provide us a minimal example that demonstrates the issue if this is possible.
            This will speed up the qualification of the ticket and illustrate better the use case.
            In case providing example is not possible, could you please share the following information:

            • pom.xml (in case of maven project)
            • application properties file or at least the part that contains the camunda configuration
            • an example of the class where the camundaBpmDataSource is created and the Application class.

            Do I understand correctly that the existence of two different data source bean means that you have two different database or the requirements for the different data source beans comes due to another reason, could you elaborate further on that?

            Best regards,
            Yana

            Yana Vasileva added a comment - Hi m_burst , Thank you for reaching out to us with this. Could you please provide us a minimal example that demonstrates the issue if this is possible. This will speed up the qualification of the ticket and illustrate better the use case. In case providing example is not possible, could you please share the following information: pom.xml (in case of maven project) application properties file or at least the part that contains the camunda configuration an example of the class where the camundaBpmDataSource is created and the Application class. Do I understand correctly that the existence of two different data source bean means that you have two different database or the requirements for the different data source beans comes due to another reason, could you elaborate further on that? Best regards, Yana

            Hi yana.vasileva,

            We have two different data source beans because we have two different databases (our main application database is separate from the database for Camunda storage).

            I'll try to provide the example during the weekend.

            Thanks,
            Mikhail

            Mikhail Burshteyn added a comment - Hi yana.vasileva , We have two different data source beans because we have two different databases (our main application database is separate from the database for Camunda storage). I'll try to provide the example during the weekend. Thanks, Mikhail

            Hi yana.vasileva,

            I've created the example and published it on Github here.

            Thanks,
            Mikhail

            Mikhail Burshteyn added a comment - Hi yana.vasileva , I've created the example and published it on Github here . Thanks, Mikhail

            Hi m_burst,

            Thank you for your example, I was able to understand better the use case.

            It doesn't seem to be a bug but rather missing configurations, please check the spring boot documentation of the default datasource configuration [1].
            Whenever a spring boot application defines more than one datasource and the primary one is not used for the process engine, you need to make sure to provide a corresponding transaction manager otherwise this could lead to inconsistencies in the database.
            Could you please have a look at the documentation and try out with separate bean for the transaction manager and share the results with us.

            Please let me know in case of any questions.

            [1]: https://docs.camunda.org/manual/7.13/user-guide/spring-boot-integration/configuration/#defaultdatasourceconfiguration

            Best regards,
            Yana

            Yana Vasileva added a comment - Hi m_burst , Thank you for your example, I was able to understand better the use case. It doesn't seem to be a bug but rather missing configurations, please check the spring boot documentation of the default datasource configuration [1] . Whenever a spring boot application defines more than one datasource and the primary one is not used for the process engine, you need to make sure to provide a corresponding transaction manager otherwise this could lead to inconsistencies in the database. Could you please have a look at the documentation and try out with separate bean for the transaction manager and share the results with us. Please let me know in case of any questions. [1] : https://docs.camunda.org/manual/7.13/user-guide/spring-boot-integration/configuration/#defaultdatasourceconfiguration Best regards, Yana

            Hi yana.vasileva,

            As far as I understand, providing a custom transaction manager would work.

            However, replacing the primary transaction manager bean seems to be a rather invasive solution, because it would affect the whole application, not only Camunda. It would lead to problems in other application code that expects the primary transaction manager to correspond to the primary datasource.

            I would suggest adding the option to provide a separate transaction manager using a bean with a qualifier (in the same way as it is done with datasources).

            Thanks,
            Mikhail

            Mikhail Burshteyn added a comment - Hi yana.vasileva , As far as I understand, providing a custom transaction manager would work. However, replacing the primary transaction manager bean seems to be a rather invasive solution, because it would affect the whole application, not only Camunda. It would lead to problems in other application code that expects the primary transaction manager to correspond to the primary datasource. I would suggest adding the option to provide a separate transaction manager using a bean with a qualifier (in the same way as it is done with datasources). Thanks, Mikhail

            Hi Mikhail,

            I am sorry for my late reply.
            I see your point and we already have a ticket to have a dedicated Camunda transaction manager in spring boot starter, you can find it here: CAM-11923.

            Please check it out and let me know if you confirm that will help with your use case.

            Are you interested in raising a pull request at https://github.com/camunda/camunda-bpm-platform/tree/master/spring-boot-starter?

            Best regards,
            Yana

             

            Yana Vasileva added a comment - Hi Mikhail, I am sorry for my late reply. I see your point and we already have a ticket to have a dedicated Camunda transaction manager in spring boot starter, you can find it here:  CAM-11923 . Please check it out and let me know if you confirm that will help with your use case. Are you interested in raising a pull request at https://github.com/camunda/camunda-bpm-platform/tree/master/spring-boot-starter ? Best regards, Yana  

            Hi yana.vasileva,

            Yes, fixing CAM-11923 would remove the problem in this issue.

            I suppose this issue can be closed in favor of CAM-11923.

            I might try to submit a pull request with the fix but I'm not sure about it at the moment.

            Thanks,
            Mikhail

            Mikhail Burshteyn added a comment - Hi yana.vasileva , Yes, fixing CAM-11923 would remove the problem in this issue. I suppose this issue can be closed in favor of CAM-11923 . I might try to submit a pull request with the fix but I'm not sure about it at the moment. Thanks, Mikhail

            Hi m_burst,

            I am closing the ticket in favor of CAM-11923.
            Please let me know if you have any questions or we can support you in case you raise a PR.

            Best regards,
            Yana

            Yana Vasileva added a comment - Hi m_burst , I am closing the ticket in favor of  CAM-11923 . Please let me know if you have any questions or we can support you in case you raise a PR. Best regards, Yana

              Unassigned Unassigned
              m_burst Mikhail Burshteyn
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: