Quartz
Reference · Applies to Brighter V10
Quartz.NET is one of the most widely used enterprise-grade scheduling libraries in the .NET community. Brighter provides first-class integration with Quartz for scheduler functionality, making it an excellent choice for production systems requiring durable, distributed scheduling.
Quartz.NET Overview
Quartz.NET is a full-featured, open-source job scheduling system that can be used from smallest apps to large-scale enterprise systems. It provides:
Persistent Job Stores: Store jobs and triggers in databases
Clustering: Run multiple scheduler instances for HA
Trigger Types: Simple, Cron, Calendar-based triggers
Job Chains: Execute jobs in sequence
Job Data: Pass data to jobs
Listeners: Monitor job execution
Plugins: Extend functionality
For more information, visit the Quartz.NET documentation.
How Brighter Integrates with Quartz
Brighter integrates with Quartz through:
QuartzBrighterJob: A Quartz job that executes scheduled Brighter messages
BrighterResolver: Custom job factory that resolves jobs from DI container
QuartzSchedulerFactory: Factory that creates Brighter's message scheduler backed by Quartz
When you schedule a message with Brighter:
Brighter creates a Quartz job with the message payload
Quartz persists the job to its job store
At the scheduled time, Quartz fires the job
QuartzBrighterJob receives the job execution
QuartzBrighterJob dispatches the message via Brighter's Command Processor
Your handler executes
Quartz NuGet Packages
Install the required NuGet packages:
For persistence, add a Quartz job store package:
Quartz Configuration
Quartz Scheduler Factory Options
QuartzSchedulerFactory takes the Quartz IScheduler as its constructor argument and exposes four properties. Everything else about Quartz — the job store, clustering, misfire policy — is configured on Quartz itself, not on Brighter's factory.
TimeProvider
TimeProvider
TimeProvider.System
The clock the scheduler measures delays against.
Group
string?
null
Names the Quartz job group scheduled jobs are created in; Quartz uses its own default group when this is null.
GetOrCreateSchedulerId
Func<Message, string>
a fresh identifier per message
Names the Quartz job Brighter creates for a message.
GetOrCreateRequestSchedulerId
Func<IRequest, string>
a fresh identifier per request
Names the Quartz job Brighter creates for a request.
The message hook is GetOrCreateSchedulerId here and GetOrCreateMessageSchedulerId on the AWS and InMemory factories; the request hook carries the same name on all three.
Basic Configuration
Configure Brighter with Quartz scheduler:
Configuration with Persistent Job Store
For production, use a persistent job store:
Configuration with appsettings.json
You can configure Quartz via appsettings.json:
Then configure with:
Persistence Options
Quartz supports multiple persistent job stores:
SQL Server
Database Scripts: SQL Server Scripts
PostgreSQL
Database Scripts: PostgreSQL Scripts
MySQL
Database Scripts: MySQL Scripts
In-Memory (Development Only)
For development, you can use the in-memory store (no persistence):
Warning: In-memory store loses all jobs on restart. Use persistent store for production.
Advanced Configuration
Custom Scheduler ID Generation
By default, Brighter uses Guid.NewGuid() for scheduler IDs. Customize this behavior:
Why customize?
Use business-meaningful IDs for better tracking
Correlate scheduled jobs with business entities
Simplify debugging and monitoring
Quartz Job Groups
Organize jobs into groups:
Benefits:
Logical organization of jobs
Easier monitoring and management
Group-level operations (pause, resume, delete)
Misfire Handling
Configure how Quartz handles missed triggers:
Quartz Code Examples
Basic Scheduling
Cancelling a Scheduled Job
Scheduling with Absolute Time
Clustering and High Availability
Quartz supports clustering for high availability:
How clustering works:
Multiple scheduler instances share the same job store (database)
Each instance regularly checks in with the job store
If an instance fails, other instances take over its jobs
Only one instance executes each job (no duplicates)
Provides automatic failover and load distribution
Best practices for clustering:
Use
SchedulerId = "AUTO"for unique instance IDsSet appropriate check-in intervals (default 20 seconds)
Use persistent job store (required for clustering)
Ensure clocks are synchronized across instances (NTP)
Monitor instance health and check-ins
Quartz Monitoring and Observability
Quartz Listeners
Monitor job execution with listeners:
Health Checks
Monitor Quartz scheduler health:
Quartz Best Practices
1. Always Use Persistent Job Store in Production
2. Enable Clustering for High Availability
3. Store Scheduler IDs for Cancellation
4. Use JSON Serialization
5. Configure Appropriate Check-In Intervals
6. Monitor Job Execution
Register a job listener, such as the BrighterJobListener shown under monitoring above, and a trigger listener (an ITriggerListener) written the same way:
7. Handle Timezone Correctly
8. Set Appropriate Connection Pool Size
Quartz Troubleshooting
Jobs Not Executing
Symptom: Jobs scheduled but never execute
Possible Causes:
Quartz scheduler not started
Database connectivity issues
QuartzBrighterJob not registered
Misfire threshold exceeded
Solutions:
Jobs Executing Multiple Times
Symptom: Same job executes on multiple instances
Cause: Clustering not configured or clock drift
Solution:
Database Deadlocks
Symptom: Database deadlocks in Quartz tables
Cause: High concurrency with insufficient connection pool
Solution:
Related Documentation
Brighter Scheduler Support - Overview of scheduling in Brighter
Switching Schedulers - Moving to or from this scheduler
InMemory Scheduler - Lightweight scheduler for testing
Hangfire Scheduler - Alternative production scheduler with dashboard
AWS Scheduler - Cloud-native AWS scheduling
Azure Scheduler - Cloud-native Azure scheduling
Quartz.NET Documentation - Official Quartz documentation
Quartz Summary
Quartz.NET is an excellent production scheduler for Brighter offering:
Durability: Jobs persisted to database survive restarts
Clustering: High availability with automatic failover
Maturity: Battle-tested in production for years
Flexibility: Rich API for complex scheduling scenarios
Reliability: Strong guarantees for job execution
Monitoring: Comprehensive monitoring and observability
Strong Naming: Fully signed assemblies for enterprise use
Use Quartz when you need a robust, enterprise-grade scheduler with clustering support and don't require a built-in dashboard (otherwise consider Hangfire).
Last updated
Was this helpful?
