Answered 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


All Replies

  • Friday, March 23, 2012 3:09 AM
    Moderator
     
     Answered

    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.