2

I'm using MYSQL with R2DBC (with spring-data-r2dbc and jasync-r2dbc-mysql) and Reactive Mongo with spring-data-mongo-reactive. I want to set transaction which includes both operations. At first, I considered JTA and ChainedTransactionManager but as I know, both of them implements PlatformTransactionManager, not ReactiveTransactionManager.

Considering that both R2DBCTransactionManager of spring-data-r2dbc and ReactiveMongoTransactionManager of spring-data-mongodb implements AbstractReactiveTransactionManager, is there any way to integrate them in one transaction?

심시은
  • 339
  • 1
  • 5
  • 21
  • 1
    I don't see why not, have you tried it? To do this with something that uses `PlatformTransactionManager`, just mark the parent method that calls both data sources with `@Transactional` – stringy05 Aug 11 '20 at 23:13
  • @stringy05 Yes, I tried but it doesn't work. And both of them does not implement `PlatformTransactionManager` but `AbstractReactiveTransactionManager.` Or do you think that reactive transaction should work similar with normal transaction as for `@Transactional`? – 심시은 Aug 12 '20 at 04:44
  • 1
    what am I talking about here? This question is basically - can spring reactive do XA (that is distributed) transactions? Not without a reactive distributed transaction manager and I dont think that exists yet, although there's some O'Reilly page that says it can be done with the SAGA pattern.. here's the link https://www.oreilly.com/library/view/hands-on-reactive-programming/9781787284951/bcb4b700-44fc-4376-a9c2-df2af3e9a2a8.xhtml but I haven't read it and cant vouch if it works or not – stringy05 Aug 12 '20 at 07:41
  • 1
    @stringy05 I newly checked that even normal Mongo does not support for XA. As you said, maybe reactive XA support does not even exist that I cannot find any reference for it.. Thank you for introducing SAGA pattern, I'll take a look about it. – 심시은 Aug 12 '20 at 08:22
  • 1
    yeah, maybe in the future someone will write a reactive version of atomikos – stringy05 Aug 12 '20 at 23:28

0 Answers0