Getting Started
Standalone is the simplest way to run JobMaster. A single database connection handles both coordination, job storage, and the transport agent layer for job execution — no additional connections required.
Register in Program.cs
The example below uses PostgreSQL. MySQL and SQL Server are also supported — see Providers for the full list.
builder.Services.AddJobMasterCluster(config =>
{
config.UseStandaloneCluster()
.ClusterId("Local-Cluster-01")
.UsePostgres("Host=localhost;Database=jobmaster_db;Username=postgres;Password=pwd")
.AddWorker();
});
var app = builder.Build();
await app.Services.StartJobMasterRuntimeAsync();
Schedule a Job
First, create a job handler:
public sealed class HelloJobHandler : IJobHandler
{
public async Task HandleAsync(JobContext job)
{
var name = job.MsgData.TryGetStringValue("Name") ?? "World";
Console.WriteLine($"Hello {name}");
await Task.CompletedTask;
}
}
Then inject IJobMasterScheduler anywhere in your app to enqueue work:
app.MapPost("/schedule-job", async (IJobMasterScheduler jobScheduler) =>
{
var msg = WriteableMessageData.New().SetStringValue("Name", "John Doe");
await jobScheduler.OnceNowAsync<HelloJobHandler>(msg);
return Results.Accepted();
}).WithOpenApi();
tip
Standalone keeps the setup simple with a single connection. For horizontal scaling, you can add dedicated databases or message brokers for the transport layer at any time — see Distributed Setup.
Next Steps
- One-off Scheduling — Immediate, delayed, and timed jobs
- Recurring Schedule — Cron and interval-based schedules
- Job Configuration — Attributes, message data, DI, and configuration hierarchy