Skip to content

IDurableJobHandler

interface

Namespace: Orleans.DurableJobs

Defines the interface for handling durable job execution. Grains implement this interface to receive and process durable jobs.
public interface IDurableJobHandler

Remarks

Grains that implement this interface can be targeted by durable jobs. The IDurableJobHandler method is invoked when the job's due time is reached.

The following example demonstrates a grain that implements IDurableJobHandler:
public class MyGrain : Grain, IDurableJobHandler
{
public Task ExecuteJobAsync(IJobRunContext context, CancellationToken attemptCancellationToken)
{
// Process the durable job
var jobName = context.Job.Name;
var dueTime = context.Job.DueTime;
// This token requests cancellation of this execution attempt, for example during silo shutdown.
// The durable job remains eligible for another attempt on another host.
attemptCancellationToken.ThrowIfCancellationRequested();
// Perform job logic here
return Task.CompletedTask;
}
}

Methods