I’m having issues creating a batch with jobs that have to process one after another.
Any ideas would be appreciated.
Thanks!
I’m having issues creating a batch with jobs that have to process one after another.
Any ideas would be appreciated.
Thanks!
Its probable that there is a job in the chain that is failing. If any job fails the subsequent will not execute. Are you catching exceptions for all jobs, can you confirm they execute successfully?
Would recommend logging each job to debug
var createTempFolder = batch.Enqueue(() =>
{
Console.WriteLine("createTempFolder Job ID: " + BatchJob.CurrentId); //or log
return CreateBoxFolderIfNeeded(x => x.ExecuteAsync(new CreateBoxFolderIfNeededRequest(), cancellationToken));
});
var moveFileToTemp = batch.ContinueJobWith(createTempFolder, () =>
{
Console.WriteLine("moveFileToTemp Job ID: " + BatchJob.CurrentId);
....
To try and identify which Job might be causing the issue.
That’s not how you use a batch. A batch is for grouping many like jobs. If you are only using continue with, you do not need to use a batch. Using a batch continue with is running a job only after the batch has completed.
It’s not an issue with any jobs failing - the issue is that the batch/jobs fail to even be created.
Is there a way to group dissimilar jobs? For example, I have a business process that requires many distinct units of work to complete across many services - I’d like to group them in some logical way (like a batch) to facilitate being able to visualize a business process to completion in the Hangfire dashboard.
Lets say I need to run this business process 1,000 times, it would be very helpful in my use-case to be able to see them as 1,000 batches rather than 8,000 jobs.
You can put any type of job in a batch. The issue is the batch is not designed to coordinate/prioritize jobs within the batch. The batch can be used to process job(s) after the batch is complete.
It’s hard to comment on your use case. You could turn each step into a batch. Have a batch for creating a temp folder, have a batch for moving the file, etc. Then you can coordinate those batches to run one after the other.