I have several method calls I need to perform that need to be "transactional" but I am unsure how to implement this aside from try/catch/finally.
Background
What I'm trying to figure out
I want to make sure that when a logout is requested I want to ensure that the entire process is either all successful, or not at all. For instance I don't want the database to be cleaned up, the session ID cleaned and the logout operation fail (hence the login is still valid).
Ideally the solution would "rollback" on a failure, thereby ensuring the previous state is maintained.
Is there is a slick way to accomplish this, or am I stuck with a series of nested try/catch/finally blocks to do this?
If you want to implement some rollback
method, you must store undo data for all the things you'll need to rollback in case of a failure.
This will allow you at any point in your code to rollback to a previous state when an error occurs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With