Skip to content

Configuration error when using multiple transaction managers #68

Description

@pzapasni

Description

In my app I have two PlatformTransactionManager beans: one for MongoDB and one for RabbitMQ. Neither of them is marked as the primary bean. I also have disabled the transactions in MongoCK via mongock.transaction-enabled: false. This setup causes an application startup error with the following message:

Parameter 3 of method connectionDriver in io.mongock.driver.mongodb.springdata.v4.config.SpringDataMongoV4ContextBase required a single bean, but 2 were found

So although the transaction usage in MongoCK has been disabled, the configuration in SpringDataMongoV4ContextBase still requires that either 0 or 1 PlatformTransactionManager beans are present, instead of ignoring those beans completely.

PRIORITY

NORMAL, since a workaround is possible by marking one of the beans as @Primary

Version and environment

Mongock

  • Mongock version: 5.3.4
  • Modules involved: mongock-springboot-v3, mongodb-springdata-v4-driver
  • How Mongock is used: annotation approach (via @EnableMongock and application.yaml)

Environment

  • Framework and libraries versions. Especially those that affect directly to Mongock(Spring, Spring data, MongoDB driver, etc.)
    Spring Boot 3.1.3, Spring Data MongoDB 4.1.3, MongoDB driver 4.9.1
  • Infrastructure: Kubernetes, Docker, SO, etc.
    N/A, issue is occurring locally

Steps to Reproduce

  1. Create a Spring Boot app with two or more PlatformTransactionManager beans
  2. Set mongock.transaction-enabled: false
  3. Start app

Behaviour

Expected behavior: [What you expect to happen]
MongoCK ignores PlatformTransactionManager beans, app starts normally

Actual behavior: [What actually happens]
An error message is displayed, app does not start

How often the bug happens: [What percentage of the time does it reproduce?]
Always

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions