I'm new to spring, started using spring boot for the project. We have a use case of implementing database changes and few external API calls as one transaction. Please suggest, is this possible with the spring @Transactional
?
Do the API calls need to be part of the transaction?
If the answer is no, I would advise to use TransactionTemplate.doInTransaction()
leaving the API requests outside of the Tx.
If you need to make the API requests inside a Tx, I would advise against it, you would be locking DB resources for the duration of those requests.
You can also search and find out more about the eventual consistency
model.