A quick port of the old Hangfire.Redis library to use StackExchange.Redis
Basic configuration mimics stock Hangfire behaviour. However, it's possible to pass your StackExchange.Redis ConfigurationOptions in directly.
There are many ways to configure Hangfire to use Hangfire.Redis.StackExchange. To get going in a hurry you can add something as simple as this to your OWIN Startup class:
using Hangfire;
using Hangfire.Redis.StackExchange;
// ...
public void Configuration(IAppBuilder app)
{
GlobalConfiguration.Configuration.UseRedisStorage("<connection string>");
app.UseHangfireDashboard();
app.UseHangfireServer();
}
If you already have a StackExchange.Redis ConfigurationOptions
class that your project uses you are able to substitute it for the connection string:
GlobalConfiguration.Configuration.UseRedisStorage(ConfigurationOptions);
Further options for configuration can be found in the RedisStorageOptions
class:
GlobalConfiguration.Configuration.UseRedisStorage("localhost:6379", new RedisStorageOptions()
{
Db = 0,
Prefix = "hangfire:"
});
You can display extra stats from your Redis server on your dashboard. If you use an admin connection by default you can do so as easily as:
GlobalConfiguration.Configuration.UseDashboardMetric(RedisStorage.GetDashboardInfo("Version", "redis_version"));
If you maintain a seperate ConnectionMultiplexer
with administrator privilages you are able to use that instead:
GlobalConfiguration.Configuration.UseDashboardMetric(RedisStorage.GetDashboardInfo(AdminMultiplexer, "Version", "redis_version"));
The above two examples select a server at random to pull INFO from. This is not an issue if you only have one Redis server, but if you have them clustered you can retrieve information from each seperately by passing an IServer
:
GlobalConfiguration.Configuration.UseDashboardMetric(RedisStorage.GetDashboardInfo(IServer, "Server 1: Version", "redis_version"));
A list of avaiable INFO keys can be found at here.
Can be found on NuGet at https://www.nuget.org/packages/HangFire.Redis.SE/
- Fixed issues with multiple queues
- Added support for changing the hangfire prefix
- Fixed issue where job status was not always being reported to the dashboard
- Fix function name in [Obsolete] sections
- Updated to support for Hangfire 1.4
- Fixed job state always being null on the dashboard
- Initial Version