Will a new transaction automatically start when calling a transactional method inside another transactional method located in different services?
sobes.tech AI
Answer from AI
In Java, the behavior of transactions when calling one transactional method from another depends on the transaction management settings and the framework used (for example, Spring).
If different services use the standard settings with propagation = REQUIRED (the default in Spring), then when calling a transactional method within another transactional method, a new transaction is not created — the existing one is used (a nested transaction is not created).
To start a new transaction within an existing one, you can use propagation = REQUIRES_NEW, which will suspend the current transaction and create a new one when the method is called.
Thus, automatic initiation of a new transaction when calling a transactional method in another service does not occur unless specified otherwise through propagation settings.