tags:

views:

104

answers:

1

Hi! Does anyone have a set of best practices they'd like to share related to Azure WorkerRole error handling? I'd particulalry like any ideas you may have on how to deal with persistent error conditions (i.e. where access to an external resource like a web service is temporarily down for several hours). Thanks.....

+1  A: 

You might check out Exception Handling Action Policies App Block for .NET for this case (curcuit breaker or simple sleep-and-retry-forever might do work).

This application block was helpful in scenarios, where connectivity between elements of the distributed system is unreliable and subject to various failures. One of the advantages is that such action policies for an entire application could be configured in place and then injected into the appropriate classes via Inversion of Control.

For example:

var policy = ActionPolicy
  .Handle<CommunicationException>()
  .CircuitBreaker(1.Minutes(), 2);

var recordSet = policy
  .Get(() => remoteRepository.GetRecords(someCriteria));

Lokad.Cloud (for Azure) open source project uses same policies from Lokad Shared Libraries.

NB: Action policies are compatible with RetryPolicies of the Azure Storage:

var policy = ActionPolicy.Handle<StorageServerException>().Retry(5);
queueService.RetryPolicy = policy.Do;
Rinat Abdullin