Deferral and Recovery as an alternative Error Strategy

Error MessageBoxes and Exits from the application code is not the only way to
handle errors in applications. If there is a chance that the error conditions
can clear up such as network temporary outages, then Deferral and Recovery may be another way to go. Here I will describe a Deferral and Recovery method used in the Genius Outlook Plug-in.

Deferral requires that the current state of the transaction be described and stored in an application space. In this application the state is described using XML and a very simple schema.  A simplified finite state machine interprets the state information and executes the protocol elements of the transaction keeping a log of each step.  The log itself is an XML based record of the transaction and can be used for diagnostic analysis and customer support.

A job table is kept of pending and Deffered jobs some sample XML follows below:

<?xml version=”1.0″ standalone=”yes”?>
<DocumentElement>
<Job_Table>
<JobIDNumber>17b50efc-6215-4da5-89a1-ae4948302e81</JobIDNumber>
<State>Sent:Local</State>
<PostedTime>6/18/2009 4:39:11 PM</PostedTime>
<ScheduledTime />
<CompletedTime>6/18/2009 4:39:13 PM</CompletedTime>
<Retries>0</Retries>
<SentItems>1</SentItems>
</Job_Table>
<Job_Table>
<JobIDNumber>c03e2dc3-a6d2-47d8-85e9-825ffaabe2a2</JobIDNumber>
<State>Sent:SG:d0266e5d02dd6b5efc910d0a9ccd95f42e1f154300405e52c2fbee49ac4457ac</State>
<PostedTime>6/21/2009 12:14:41 PM</PostedTime>
<ScheduledTime />
<CompletedTime>6/21/2009 12:14:43 PM</CompletedTime>
<Retries>0</Retries>
<SentItems>0</SentItems>
</Job_Table>

Items posted but not sent are deferred by definition.  Recovery may ocurr at any time the resources for the transaction are available. Recovery may be scheduled by indicating a   <ScheduledTime Time Value<ScheduledTime /> entry in the XML job table record.  The transaction record keeps the infromation about the progress of the transaction and whether it has failed at any point.

A sample of this XML record follows below:

<?xml version=”1.0″ standalone=”yes”?>
<DocumentElement>
<Error_table>
<TransactionID>485c1ce1-e681-4c43-aaee-41fa5cb6a80e</TransactionID>
<SequenceNumber>1</SequenceNumber>
<FunctionExecuted>MGCountBodyLinks</FunctionExecuted>
<State>Posting</State>
<PostedTime>4/28/2009 2:42:00 PM</PostedTime>
<ScheduledTime>4/28/2009 2:42:00 PM</ScheduledTime>
<CurrentTime>4/28/2009 2:42:00 PM</CurrentTime>
<Result>&lt;links=1&gt;&lt;merge_errors=0&gt;&lt;phishing_links=0&gt;</Result>
<JobIDNumber>895c01a4-d55e-4e63-8c86-8a4a749b7645</JobIDNumber>
</Error_table>
<Error_table>
<TransactionID>8131d643-77e4-4b21-b1aa-3e94c65afe7f</TransactionID>
<SequenceNumber>2</SequenceNumber>
<FunctionExecuted>MGCheckEmailBudget</FunctionExecuted>
<State>Posting</State>
<PostedTime>4/28/2009 2:42:21 PM</PostedTime>
<ScheduledTime>4/28/2009 2:42:21 PM</ScheduledTime>
<CurrentTime>4/28/2009 2:42:21 PM</CurrentTime>
<Result>Budget Returned:=1</Result>
<JobIDNumber>895c01a4-d55e-4e63-8c86-8a4a749b7645</JobIDNumber>
</Error_table>
<Error_table>
<TransactionID>6f2a3e80-9fd8-471a-9b2f-9f4afba0b114</TransactionID>
<SequenceNumber>3</SequenceNumber>
<FunctionExecuted>MGTestLogin</FunctionExecuted>
<State>Sending</State>
<PostedTime>4/28/2009 2:42:24 PM</PostedTime>
<ScheduledTime>4/28/2009 2:42:24 PM</ScheduledTime>
<CurrentTime>4/28/2009 2:42:24 PM</CurrentTime>
<Result>Login successful</Result>
<JobIDNumber>895c01a4-d55e-4e63-8c86-8a4a749b7645</JobIDNumber>
</Error_table>

When the error condition clears up the job can be recovered and the upon sucessful completion the job status table is updated.

Time-outs  or retries can be added to limit the number of attempts to complete the job.  When the job is completed.  An Archive folder can be created to store completed job records on a regular basis. The folders can be cleaned on scheduled basis.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Twitter
  • Google Bookmarks
  • DZone
  • HackerNews
  • LinkedIn
  • Reddit