8000 Support for multiple PlatformTransactionManagers (Spring integration) · Issue #702 · mongock/mongock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Support for multiple PlatformTransactionManagers (Spring integration) #702
Open
@rfelgent

Description

@rfelgent

Description

If multiple PlatformTransactionManagers are configured, Mongocks bootstrapping logic fails with the error "Multiple PlatformTransactionManager candidates are found" (this is a typical Spring dependency injection failure!)

PRIORITY

NORMAL

Version and environment

Mongock

  • Mongock version: 5.4.0 (I think every version suffers from this error since the introduction of SpringDataMongoV4Context)
  • Modules involved: SpringBoot v3.4.3, MongoDB 7.0
  • How Mongock is used: annotation approach

Environment

  • SpringBoot, Spring Data MongoDB and Spring Data JDBC
  • Infrastructure: Kubernetes

Steps to Reproduce

  1. Define multiple beans of PlatformTransactionManager, e.g.:
  @Bean
  MongoTransactionManager mongoTransactionManager() {
    ...
  }
  @Bean
  DataSourceTransactionManager jdbcTransactionManager() {
      ...
  }
  @Bean
  RabbitTransactionManager rabbitTransactionManager() {
      ...
  }

Behaviour

Expected behavior:

Depends on the prefered solution/conception how to handle multiple PlatformTransactionManagers.
My minimum wish: silent/graceful skip when multiple PlatformTransactionManagers are found (which in turns disables the transactional support of Mongock)

Actual behavior:
Spring fails to wire the SpringDataMongoV4Context or more concrete SpringDataMongoV4ContextBase#connectionDriver due to its method signature:

@Bean
  public ConnectionDriver connectionDriver(MongoTemplate mongoTemplate, CONFIG config, MongoDBConfiguration mongoDbConfig, Optional<PlatformTransactionManager> txManagerOpt) {
    DRIVER driver = this.buildDriver(mongoTemplate, config, mongoDbConfig);
    this.setGenericDriverConfig(config, txManagerOpt, driver);
    this.setMongoDBConfig(mongoDbConfig, driver);
    driver.initialize();
    return driver;
  }

Injection of Optional<PlatformTransactionManager> fails, as multiple beans of that type exist!

How often the bug happens:

100%

Additional context

There is a similar issue but it is already closed/solved: #676

Metadata

Metadata

Assignees

No one assigned

    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

      0