CompensableActivity & retrieve Exception
-
Wednesday, March 21, 2012 7:00 AM
Hi,
I've a TransactionScope within the body of a CompensableActivity.
In case of exception I want the TransactionScope to rollback the DB changes and I'd like the CompensationHandler to log the exception.
My CompensationHandler is not executed in case of exception. Why ?
How can I retrieve the exception from within the CompensationHandler ?
Thanks.
philippe
- Edited by philippe lombaers Wednesday, March 21, 2012 7:26 AM
All Replies
-
Friday, March 23, 2012 3:09 AMModerator
Hi,
"The difference between exception handling and compensation is that exception handling occurs during the execution of an activity. Compensation occurs after an activity has successfully completed. Exception handling provides an opportunity to clean up after the activity raises the exception, whereas compensation provides a mechanism by which the successfully completed work of a previously completed activity can be undone."
You can use the OnUnhandledException event handler or TryCatch activity to handle exceptions. For more information, please refer to:
Exceptions
http://msdn.microsoft.com/en-us/library/dd489406.aspx
Thanks.
Leo Tang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked As Answer by LeoTangModerator Wednesday, March 28, 2012 8:30 AM

