public void MapEndpoint(IEndpointRouteBuilder app) {
app.MapGet("/hangfireTest", async (NectaContext context, [FromServices] VendorCatalogHttpClient httpClient) => {
var parentId = BatchJob.StartNew(batch =>
{
batch.Enqueue(HangfireQueue.Debug.Name(), () => Console.WriteLine("STARTED: Parent Job 1"));
batch.Enqueue(HangfireQueue.Debug.Name(),() => FailingJob()); // Eror!
batch.Enqueue(HangfireQueue.Debug.Name(), () => Console.WriteLine("STARTED: Parent Job 3"));
}, description: "Parent-Batch");
BatchJob.ContinueBatchWith(parentId, batch =>
{
batch.Enqueue(HangfireQueue.Debug.Name(), () => Console.WriteLine("STARTED: Child Batch was started!"));
batch.Enqueue(HangfireQueue.Debug.Name(), () => Console.WriteLine("STARTED: Child Job 2"));
}, options: BatchContinuationOptions.OnlyOnCompletedState, description:"Child-Batch");
return Results.Ok("Batch started!");
})
.WithName("HangfireTest")
.WithTags("Dummy")
.WithOpenApi();
}
[AutomaticRetry(Attempts = 0)]
public void FailingJob() {
Console.WriteLine("ERROR: This is an error job");
throw new Exception("Simulated Error in Parent Batch");
}
the Parent job stays in state “Started”… Items “Not Finished” 1/3
the Child job stays in state “Awaiting”…
even without option BatchContinuationOptions.OnlyOnCompletedState!
I just want to know why.
