How to handle batch jobs without Hangfire Pro

I included Hangfire in my project. Now I have a need to insert some tasks that will be technically part of the package. The company will not buy the Pro version of Hangfire, which offers bundled functionality. Is there a workaround so that I can tell when all related tasks are complete so that I can call another function at the very end of each batch?

Example:

Batch A:
{
  BackgroundJob.Enqueue(jobA1);
  BackgroundJob.Enqueue(jobA2);
  BackgroundJob.Enqueue(jobA3);
}

When Batch A is all done: 
  BackgroundJob.Enqueue(createReportForBatchA);

Batch B:
{
  BackgroundJob.Enqueue(jobB1);
  BackgroundJob.Enqueue(jobB2);
  BackgroundJob.Enqueue(jobB3);
}

When Batch B is all done: 
  BackgroundJob.Enqueue(createReportForBatchB);

, , "" , , , , , Enqueue createReportForBatch. , , , BackgroundJob ( ). .

+4
2

1.

API , . , , "" , , , .

. , , ( , ..).

2. Hangfire + TPL

Hangfire + TPL , . , Batch A - , Batch B - . A B TPL jobAN Task.WaitAll .

+3

Hangfire , Hangfire: http://docs.hangfire.io/en/latest/background-methods/using-batches.html#chaining-batches. BackgroundJob.Continue :

var id = BatchJob.StartNew(
{
  BackgroundJob.Enqueue(jobA1);
  BackgroundJob.Enqueue(jobA2);
  BackgroundJob.Enqueue(jobA3);
});

BatchJob.ContinueWith(id, x => {
  BackgroundJob.Enqueue(createReportForBatchA);
});
0

Source: https://habr.com/ru/post/1625561/


All Articles