Hongyi Li
Hongyi Li

Reputation: 1079

How to reliably make sure both local and remote copies of data are updated, even if server fails halfway

This is an infrastructure question. I have a Java web app that allows users to make 'transactions'. This transaction first calls a remote service and updates info there, and once it receives an ack from the remote service saying that the info has been successfully updated there, it will do some local computation and record the transaction in a local database.

So my question is, what happens if the remote service records the change, but somehow my server fails to compute and record it in the local database? Say the power goes off right when the remote service completes but before the local update occurs. Then there is a mismatch between the remote and local data, and consistency is violated. How do I take care of this scenario?

Also, is there any open source tools etc that can help me take care of this problem? For example let's say if the solution is to use a log-based rollback mechanism, I would hate to have to implement that all by myself.

Thanks in advance for the help! :)

Upvotes: 0

Views: 33

Answers (1)

sanj
sanj

Reputation: 391

Have you tried XA transaction? Have a look this page: http://java.dzone.com/articles/xa-transactions-2-phase-commit.

Upvotes: 2

Related Questions