Skip to content
Hangfire background job activator based on Stashbox (https://github.com/z4kn4fein/stashbox)
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Renaming May 9, 2019
test Renaming May 9, 2019
.gitignore Initial commit Apr 20, 2019
.travis.yml Fix build config May 7, 2019
LICENSE Initial commit Apr 20, 2019
README.md Update README.md [skip ci] May 10, 2019
appveyor.yml Fix build script May 9, 2019
patch-version.ps1 Add ci and tests May 6, 2019
stashbox.hangfire.sln Add ci and tests May 6, 2019

README.md

stashbox-hangfire

Appveyor build status Travis CI build status NuGet Version

This project provides Stashbox integration for Hangfire, using Stashbox container and Scopes to resolve jobs and their dependencies.

Common usage

To integrate Stashbox as the default JobActivator into Hangfire, you can use the UseStashboxActivator extension method on the IGlobalConfiguration interface.

var container = new StashboxContainer();

GlobalConfiguration.Configuration.UseStashboxActivator(container);

ASP.NET Core

The ASP.NET Core extension of Hangfire uses the built-in IServiceProvider to resolve jobs through an AspNetCoreJobActivator, so for using Stashbox as the default job activator you can simply just use the ASP.NET Core integration of Stashbox which replaces the default IServiceProvider with a Stashbox container.

However you also have the option to tell Hangfire that it should use the StashboxJobActivator directly.

public IServiceProvider ConfigureService(IServiceCollection services)
{
    services.AddHangfire((provider, config) => 
        config.UseStashboxActivator(provider.GetService<IDependencyResolver>()));

    return services.UseStashbox();
}

.NET Generic Host

using (var host = new HostBuilder()
    .UseStashbox()
    .ConfigureContainer<IStashboxContainer>((context, container) =>
    {
        container.Register<JobActivator, StashboxJobActivator>();
    })
    .ConfigureServices((context, services) =>
    {
        services.AddHangfireServer();
    })
    .Build())
{
    // start and use your host
}
You can’t perform that action at this time.