Introduction
Coravel brings the ease of Laravel's task scheduling and queuing to .NET. Instead of setting up external job servers or cron daemons, you define scheduled tasks and background jobs in your application code with a fluent API that reads like English, all within the built-in DI container.
What Coravel Does
- Schedules recurring tasks with a fluent cron-like API (daily, weekly, hourly, custom intervals)
- Queues background jobs for async processing without external infrastructure
- Provides an in-process event broadcasting system with listeners
- Includes a lightweight caching layer with driver abstraction
- Sends templated emails using Razor views with a built-in mailer
Architecture Overview
Coravel runs as hosted services within the ASP.NET Core process. The scheduler ticks on a one-minute interval and evaluates which IInvocable tasks are due based on their configured schedule. Queued tasks run on a background thread pool managed by the framework. All components integrate through IServiceCollection, so they have full access to DI-registered services, database contexts, and configuration. No external message brokers or schedulers are needed.
Self-Hosting & Configuration
- Install via NuGet:
dotnet add package coravel - Register the scheduler, queue, or other features in
Program.cs - Implement
IInvocablefor each scheduled task or queued job - Configure the mailer with SMTP settings via
appsettings.json - Use
Coravel.Pro(optional) for a dashboard UI to monitor tasks
Key Features
- Fluent scheduling API:
.Daily(),.Weekly(),.Cron("0 */6 * * *"),.EveryMinute() - In-process job queue with error handling and retry support
- Event broadcasting with multiple listeners per event
- Razor-based email templates with SMTP or custom mail drivers
- No external dependencies: runs entirely within the ASP.NET Core host
Comparison with Similar Tools
- Hangfire — persistent job storage with dashboard; Coravel is lighter with in-process scheduling
- Quartz.NET — enterprise-grade scheduler; Coravel trades clustering for simplicity
- Azure Functions Timer Trigger — cloud-specific; Coravel runs anywhere your app runs
- System.Threading.Timer — low-level; Coravel adds DI, fluent API, and error handling
- BackgroundService — manual hosted service; Coravel provides a structured scheduling layer on top
FAQ
Q: Does Coravel persist scheduled tasks across restarts? A: No. Coravel's scheduler is in-memory. For persistent job queues, consider Hangfire or Quartz.NET. Coravel is designed for tasks defined in code that run within the application lifecycle.
Q: Can I run tasks on multiple instances? A: Coravel schedules are per-instance. For distributed locking, you would need to add an external lock mechanism or use a single-instance deployment.
Q: How do I handle task failures?
A: Use .OnError(exception => ...) on the scheduler or queue to handle and log errors per-task.
Q: What is the difference between scheduled tasks and queued jobs? A: Scheduled tasks run on a recurring time-based schedule. Queued jobs are triggered by your code and processed asynchronously in the background.