Piscal Queue working more resilient to error

This commit is contained in:
2016-04-18 10:44:36 -04:00
parent 6623aa48ea
commit ca1a235c1d
21 changed files with 418 additions and 176 deletions
+39
View File
@@ -0,0 +1,39 @@
using System;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Remote;
namespace LeafWeb.Web.Services
{
public abstract class PiscalQueueWorker : PiscalQueueBase
{
public void DoWork(int leafInputId)
{
LeafInput leafInput = null;
try
{
leafInput = DataService.GetLeafInput(leafInputId);
DoWorkInternal(leafInput);
}
catch (PiscalClientException ex)
{
PiscalExceptionNotify(ex, leafInput);
if (leafInput != null)
{
DataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Exception, "Error occurred processing LeafInput",
ex.Message);
}
// signal to process next item
HangfireStartup.TriggerPiscalProcessQueue();
}
catch (Exception ex)
{
var errorMessage = FormatException(ex, leafInputId);
Logger.Error(errorMessage);
throw; // this will retry via HangFire
}
}
protected abstract void DoWorkInternal(LeafInput leafInputId);
}
}