I am using hibernate to persist our data. We have a user sign up screen and we ask for credit card number. we associate credit card number with a user account during the registration process. We create a userAccount and persist to database and then try to register credit card for the user.
The credit card registration process is a seperate process running as a daemon . It's a network application. Our problem is that we have to have a user account to register a credit card(due to the original design). But the credit card registration process could fail(network or other exceptions).
My question is how could we group these two actions(user account persistence and credit card registration) into one transaction, so that if the credit card registration process fails we could roll back the userAccount persistence?
Currently we delete the user Account if credit card registration fails.
You need to wrap the whole business transaction is a JTA transaction. It will need to be an XA transaction, since you are using both a DB and a networked app. So your JDBC driver will have to support two-phase commit.