Closed mhkolk closed 1 year ago
Oic there is a Hangfire.NetCore package (https://www.nuget.org/packages/Hangfire.NetCore/1.7.33) which is not mentioned anywhere and there is no section in Docs under Getting Started for .NET Core (only ASP.NET and ASP.NET Core). You might want to consider adding that bc it is really easy to miss that.
I only learned from it now when I tried to run the app without the registration to see what the BackgroundJob.Enqueue will say when no Hangfire configuration is present and it prints out the error
Current JobStorage instance has not been initialized yet. You must set it before using Hangfire Client or Server API.
For .NET Core applications please call the `IServiceCollection.AddHangfire` extension method from **Hangfire.NetCore** or **Hangfire.AspNetCore**
package depending on your application type when configuring the services
and ensure service-based APIs are used instead of static ones,
like `IBackgroundJobClient` instead of `BackgroundJob` and `IRecurringJobManager` instead of `RecurringJob`.
@odinserj Would it be possible to pin this issue, at least temporarily? I managed to miss this, as well, and couldn't figure out why I couldn't get the Enqueue method to work properly.
IBackgroundJobClient
and IRecurringJobManager
services should be used instead of static BackgroundJob
and RecurringJob
classes on newer .NET platforms, since they have built-in dependency injection. Will update the docs one day.
IBackgroundJobClient
andIRecurringJobManager
services should be used instead of staticBackgroundJob
andRecurringJob
classes on newer .NET platforms, since they have built-in dependency injection. Will update the docs one day.
Can't remember - are the docs a Github project? If so, I'd be happy to do PR.
I see this: https://github.com/HangfireIO/Hangfire.Documentation - if that's the correct repo, I'll carve out some time to see where I can suggest some updates.
This is an issue I ran into when I tried to start Hangfire within the .NET Core Worker service(ref https://learn.microsoft.com/en-us/dotnet/core/extensions/workers). Atm I cannot get Hangfire to work using the call to
services.AddHangfire();
without adding ASP.NET Core packages but those are not required for Workers.
The above call/services registration without ASP.NET Core packages installed will result in Worker failing to start and this being logged in the Output
My exact configuration is just this
services.AddHangfire(config => config.UsePostgreSqlStorage(hangfireDbString));
The docs talk about using Hangfire without ASP.NET and say "Hangfire.Core is enough" (https://docs.hangfire.io/en/latest/background-processing/processing-jobs-in-console-app.html) but this does not seem to be the case.
UPDATE: This worker will only act as a Hangfire client, server job processing will be done separately (albeit also within a Worker).
?