Is there an in memory job storage package for Hangfire?

走远了吗. 提交于 2019-12-04 00:07:27

You can use Hangfire.MemoryStorage for this.

Simply add this nuget package.

And then you can use it like -

GlobalConfiguration.Configuration.UseMemoryStorage();

For NET Core (web application):

Just to make it very obvious because it wasn't obvious to me.

Install following nuget packages:

  • Hangfire.AspNetCore (v1.6.17 atow)
  • Hangfire.MemoryStorage.Core (v1.4.0 atow)

In Startup.cs:

    public void ConfigureServices(IServiceCollection services)
    {
        // other registered services
        ...

        services.AddHangfire(c => c.UseMemoryStorage());
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        // other pipeline configuration            
        ...

        app.UseHangfireServer();

        app.UseMvc();
    }

Anything less than above and my enqueued method did not fire.

As Yogi said, you can use Hangfire.MemoryStorage or Hangfire.MemoryStorage.Core (for .Net Core).

What is missing in that answer is the complete code (for .Net Core) that needs to be put inside ConfigureServices(..) :

var inMemory = GlobalConfiguration.Configuration.UseMemoryStorage();
services.AddHangfire(x => x.UseStorage(inMemory));
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!