spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
704 stars 694 forks source link

Allow ReactiveFirestoreTransactionManager to be disabled while other FirestoreReactiveAutoConfiguration beans remain usable #2550

Closed sohoffice closed 2 years ago

sohoffice commented 3 years ago

Is your feature request related to a problem? Please describe. I was mixing JPA with GCP firestore and rely on JPA transaction. However, as FirestoreReactiveAutoConfiguration is always enabled by autoconfigure, I'd need to specifically declare which transaction manager to use in @Transactional.

@Transactional("transactionManager")

However, only JPA transaction manager is used, this is a little frustrating. And quite frankly very easily forgotten.

If the @Transactional annotation doesn't specify the transaction manager, Spring will complain about too many transaction manager candidates.

Describe the solution you'd like If possible, can a property be matched to control whether this bean is needed ?

meltsufin commented 3 years ago

I guess we can move the transaction manager bean to a separate auto-configuration class like we do for Datastore (DatastoreTransactionManagerAutoConfiguration). Then it will be easier to disable it.

@dmitry-s What do you think?

dmitry-s commented 3 years ago

@meltsufin we can create a configuration property spring.data.gcp.firestore.disableTransactionManager and make the TransactionManager bean conditional on that property.

What do you think?

meltsufin commented 3 years ago

I would rather move the config to a separate class like we did for Datastore. This will naturely lend itself to a ...enabled property, as well as become easy to disable with the standard spring.autoconfigure.exclude mechanism.

elefeint commented 2 years ago

Fixed in GoogleCloudPlatform/spring-cloud-gcp#620.