[spring] ChainedTransactionManager deprecated from boot 2.5
한 트랜젝션에서 서로 다른 DB에 update/insert 작업을 연속적으로 하게 될 때 이를 하나의 트랜젝션으로 보존할 수 있도록 스프링에서는 ChainedTransactionManager라는 클래스를 제공해주었다.
물론 이는 1, 2 -> 2, 1 구조로 완벽한 commit/rollback 로직은 아니었지만, 대부분/정상적인/예측 가능한 로직 상 사용 가능한 대안이었다.
참고) 1, 2 -> 2, 1 구조란?
위와 같은 구조로 2 커밋 후 1 롤백 시, 2가 롤백되지 않는 단점이 있다.
참고) 완벽한 로직이 아닌 이유: https://taes-k.github.io/2020/06/09/chained-transaction-manager/
ChainedTransactionManager 데이터소스 트랜잭션 연결하기
다중 데이터소스 트랜잭션 연결 요새는 MSA로 시스템을 구축하여 서버와 DB도 모두 각각 분리하여 마이크로하게 시스템 설계를 하는 추세이지만, 서비스에 따라 여러가지 이유로인해 여러개의 Da
taes-k.github.io
허나 springboot 2.6.2에서 사용하려고 봤더니 아래와 같이 deprecated 되었다고 나오는 것이 아닌가..
//deprecated since 2.5
@Deprecated
public class ChainedTransactionManager implements PlatformTransactionManager
그래서 대안이 뭔고 봤더니, TransactionSynchronization를 사용하라고 한다.
Instead of using ChainedTransactionManager for attaching callbacks to transaction commit (pre commit/post commit), either register a TransactionSynchronization to explicitly follow transaction cleanup with simplified semantics in case of exceptions.
See Also: TransactionSynchronization.beforeCommit(boolean), TransactionSynchronization.afterCommit()
저게 어떤 역할을 하는지, 어떻게 사용하는지는.. 좀 더 공부가 필요하다.
참고)
chainedTransactionConfig? https://techfinanceworld.com/?p=494
Chained Transaction Manager in Spring
Suppose we have multiple databases to which we need to query under a spring transaction. So just a @transactional annotation against a single database transaction manager won't work. So for multi resource, we can use XA i.e; instead of multiple transaction
techfinanceworld.com
스프링 진영에서 없애려는 이유 https://github.com/spring-projects/spring-data-commons/issues/2232
Deprecate ChainedTransactionManager [DATACMNS-1817] · Issue #2232 · spring-projects/spring-data-commons
Mark Paluch opened DATACMNS-1817 and commented ChainedTransactionManager is the primary class in org.springframework.data.transaction that is used for multi-transactionmanager arrangements. It is u...
github.com