Skip to content

peterdamm/Hangfire.Mongo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hangfire.Mongo

Build status Nuget version

MongoDB support for Hangfire library. By using this library you can store all jobs information in MongoDB.

Installation

To install Hangfire MongoDB Storage, run the following command in the Nuget Package Manager Console:

PM> Install-Package HangFire.Mongo

Usage

public void Configuration(IAppBuilder app)
{
    GlobalConfiguration.Configuration.UseMongoStorage("<connection string>", "<database name>");

    app.UseHangfireServer();
    app.UseHangfireDashboard();
}

For example:

public void Configuration(IAppBuilder app)
{
    GlobalConfiguration.Configuration.UseMongoStorage("mongodb://localhost", "ApplicationDatabase");

    app.UseHangfireServer();
    app.UseHangfireDashboard();
}

Custom collections prefix

To use custom prefix for collections names specify it on Hangfire setup:

public void Configuration(IAppBuilder app)
{
    GlobalConfiguration.Configuration.UseMongoStorage("<connection string>", "<database name>",
        new MongoStorageOptions { Prefix = "custom" } );

    app.UseHangfireServer();
    app.UseHangfireDashboard();
}

Custom Mongo DB settings

To use custom Mongo DB connection settings you can use MongoClientSettings object from Mongo DB driver package. In this case just use it instead of passing connection string when you configure your storage.

public void Configuration(IAppBuilder app)
{
    GlobalConfiguration.Configuration.UseMongoStorage(new MongoClientSettings()
            {
                // ...
                IPv6 = true
            }, "ApplicationDatabase");

    app.UseHangfireServer();
    app.UseHangfireDashboard();
}

License

Hangfire.Mongo is released under the MIT License.

About

Mongo DB support for Hangfire

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 90.5%
  • JavaScript 6.3%
  • PowerShell 3.0%
  • Other 0.2%