At first, your understanding is correct. See spring declarative transaction management documentation.

I suppose you are making an external service call within a transaction because you want the database changes to be rolled back in case of an exception. Or, in other words, you want the database updates to reflect the state of the external service call.
If so, you cannot move it outside of the transaction. In this case, you should either increase the size of the connection pool, or perhaps you can delegate lengthy transactions to a dedicated server node that processes them. This would save, for example, the "main" server node that processes user requests from lengthy transactions.
And you should think about data consistency. Is it really necessary for the database update to be synchronized with an external service call? Can an external service call be moved outside the transaction?
source share