But we have encountered an edge case where the Continuations job seem to be not executed in some ca
Setup ( Hangfire Version 1.7.6) - Running over 8 Servers
GlobalConfiguration.Configuration
.UseSqlServerStorage(“ConnectionString…..”, new SqlServerStorageOptions
{
DisableGlobalLocks = true,
});
Below is the piece of code we think we have seen issues we create Continuations of jobs based on the list.
We have seen couple issues with the Continuations job.
-
In some cases the Continuations job is not being invoked at all.
-
While reading the return value of InsertOrderToBroker within UpdateOrderInsertionStatus I receive NULL result. foreach (var investmentInstructionBulkOrder in investmentConfirmedBulkOrders) { var confirmCNoteJobId = _backgroundJobClient.Enqueue<IOrderBookingService>(x=>x.InsertOrderToBroker(investmentInstructionBulkOrder)); _backgroundJobClient.ContinueJobWith<IOrderBookingService>(confirmCNoteJobId, x => x.UpdateOrderInsertionStatus(confirmCNoteJobId, investmentInstructionBulkOrder.Order)); }
public int? InsertOrderToBroker(InvestmentInstructionBulkOrder investmentOrder)
{ var sequenceId = getfromAPI();/// // We are expecting the return value to be used by the child //step and being retrived by the GetDataFromHangFireStorage method return sequenceId; }
public void UpdateOrderInsertionStatus(string confirmCNoteJobId, InvestmentOrder investmentOrder)
{
var sequenceId = GetDataFromHangFireStorage<int?>(confirmCNoteJobId);
// Some cases we receive NULL from the GetDataFromHangFireStorage might be some dirty read happening.
if (sequenceId.HasValue)
{
}
}
public T GetDataFromHangFireStorage<T>(string jobId)
{
var data = default(T);
var api = JobStorage.Current.GetMonitoringApi();
var jobDto = api.SucceededJobs(0, int.MaxValue)
.FirstOrDefault(job => job.Key == jobId).Value;
if (jobDto?.Result != null)
{
data = JsonConvert.DeserializeObject<T>(jobDto.Result.ToString());
}
return data;
}