How to group a record in a database and write a spreadsheet in a single "transaction",

I have a Java program that writes results to both a database (SQL Server) and a spreadsheet (POI), and it would be better if none of them were written if there is an error.

It would be much worse if a spreadsheet were created, and then an error occurred while loading to the database, so I first make a DB record. However, I am wondering if anyone knows of a way to guarantee them success or failure as a unit.

Thank!

+3
source share
3 answers

XA (, ). SQL Server XA; XADisk , XA.

+1

Currently, we use the following approach to send letters in a transaction: EMails are written to the database table in the transaction, and the auxiliary thread takes them out and sends them asynchronously. The latter can be repeated several times, which makes us really sure that emails will leave if they can. The same thing happens when calling a report server, FAX server, etc.

0
source

Source: https://habr.com/ru/post/1744191/


All Articles