Skip to content

SchedulerQueueCreation

blehnen edited this page Nov 10, 2026 · 5 revisions

Job Scheduler Queue Creation

By default, the scheduler creates queues with the default settings of the transport. You can pass in your own queue creation module to pick the options that the scheduler uses. For example, this code makes the scheduler use a SQL server queue in which transactions are enabled.

This example assumes that a scheduler instance named 'scheduler' already exists.

var queueConnection = new QueueConnection("sampleSQL", connectionString);
using (var jobQueueCreation =
	new JobQueueCreationContainer<SqlServerMessageQueueInit>())
{
	using (var createQueue = jobQueueCreation.GetQueueCreation<SqlServerJobQueueCreation>(queueConnection))
	{
    	createQueue.Options.EnableDelayedProcessing = false;
        createQueue.Options.EnableHeartBeat = false;
        createQueue.Options.EnableHoldTransactionUntilMessageCommitted = true;
        createQueue.Options.EnableStatus = true;
        scheduler.AddUpdateJob<SqlServerMessageQueueInit>(createQueue,
        "test job5",
        queueConnection,
        "* * * * *",
        (message, workerNotification) => Console.WriteLine(message.MessageId.Id.Value));
    }
}

If the queue does not already exist, it is created with the options above.

The schedule uses a standard 5-field cron expression (minute hour day-of-month month day-of-week). For second-level granularity, use a 6-field expression with a leading seconds column. See Job Scheduler for cron syntax details.

Clone this wiki locally