[Discussion] exception (error) Handling in Wf

Source: Internet
Author: User
I have been working on WF recently and have encountered some problems and experiences to share with you and discuss them. This issue focuses on exception handling.
As far as I know, in WF, once a process instance is started, whether it is running correctly or wrong, whether it is a systemic error or a business error, the instance status is eventually migrated to the closed status and serialized. Of course, an error, cancellation, or compensatory event may occur.
In this way, there will be a major problem, that is
Some exceptions can be manually corrected. The extreme example is in the debugging process. However, WF enters the preset error handling process no matter what the situation, and closes the instance at the end, so that once an exception occurs, even if I fix the problem, I have to try again, this is a headache for me.
What I need is that, in some cases, exceptions can be rectified and re-transmitted. The instance data will not be saved or compensated; in some cases, the current WF processing method is required.
So what if it is implemented?
My approach is to establish an independent Exception Handling Mechanism to differentiate the WF preset methods. Both methods coexist.
The procedure is as follows:
1. I have created the exception attribute in the base class of all activities as the runtime attribute;
2. When an exception can be corrected again (whether systemic or business), set this attribute and immediately close the activity;
3. When its parent activity detects that its exception attribute is assigned a value, it also closes itself until the root activity;
4. the serialization service starts. You must customize the serialization service and check whether the exception attribute of the root activity is assigned a value in the SAVE method. If yes, the serialization action is ignored, and record exceptions.
The above implementation method is very simple and flexible, but if you use the default WF hierarchical activity, the exception transmission will be very difficult, and the previous linear method will be used, you only need to pass a layer.

PS: another problem with this method is that you need to add try to all methods... catch quickly captures exceptions and sets the basic class attributes. Otherwise, the WF preset mode will still be used. This is a headache. If someone knows how to avoid this, please kindly advise. Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.