MySql storage implementation of Hangfire - fire-and-forget, delayed and recurring tasks runner for .NET. Scalable and reliable background job runner. Supports multiple servers, CPU and I/O intensive, long-running and short-running jobs.
Some features of MySql storage implementation is under development!
Install MySQL
Run the following command in the NuGet Package Manager console to install Hangfire.MySqlStorage:
Install-Package Hangfire.MySqlStorage
Use one the following ways to initialize MySqlStorage
:
- Create new instance of
MySqlStorage
with connection string constructor parameter and pass it toConfiguration
withUseStorage
method:
GlobalConfiguration.Configuration.UseStorage(
new MySqlStorage(connectionString));
- Alternatively one or more options can be passed as a parameter to
MySqlStorage
:
GlobalConfiguration.Configuration.UseStorage(
new MySqlStorage(
connectionString,
new MySqlStorageOptions
{
TransactionIsolationLevel = IsolationLevel.ReadCommitted,
QueuePollInterval = TimeSpan.FromSeconds(15),
JobExpirationCheckInterval = TimeSpan.FromHours(1),
CountersAggregateInterval = TimeSpan.FromMinutes(5),
PrepareSchemaIfNecessary = true,
DashboardJobListLimit = 50000,
TransactionTimeout = TimeSpan.FromMinutes(1),
}));
Description of optional parameters:
TransactionIsolationLevel
- transaction isolation level. Default is read committed.QueuePollInterval
- job queue polling interval. Default is 15 seconds.JobExpirationCheckInterval
- job expiration check interval (manages expired records). Default is 1 hour.CountersAggregateInterval
- interval to aggregate counter. Default is 5 minutes.PrepareSchemaIfNecessary
- if set totrue
, it creates database tables. Default istrue
.DashboardJobListLimit
- dashboard job list limit. Default is 50000.TransactionTimeout
- transaction timeout. Default is 1 minute.
Hangfire provides a dashboard Currently dashboard is under development
Please use Visual Studio or any other tool of your choice to build the solution
In order to run unit tests and integrational tests set the following variables in you system environment variables (restart of Visual Studio is required):
Hangfire_SqlServer_ConnectionStringTemplate
(default: server=127.0.0.1;uid=root;pwd=root;database={0};Allow User Variables=True
)
Hangfire_SqlServer_DatabaseName
(default: Hangfire.MySql.Tests
)