Hi
I have been playing around with Hangfire today and really liking it, but I have come up with a couple of questions.
- In the docs (and a few blog postings) I keep seeing references to a HangFireConfig.cs file that should have been installed during the Nuget installation process. I’m not seeing this. I am trying to figure out how to create 2 different named queues in an ASP.Net MVC application. The code that should show in the config file looks like this:
var options = new BackgroundJobServerOptions
{
Queues = new[] { "critical", "default" }
};
var server = new AspNetBackgroundJobServer( options );
but I can’t figure out where to put this code, otherwise. So when my controller action fires, it puts my job in the new named queue “tester”, but it doesn’t fire. Here is my controller sample:
namespace Hangfire.Client.Controllers
{
public class TestController : Controller
{
public string Fire()
{
var id = BackgroundJob.Enqueue(() => System.Diagnostics.Debug.WriteLine("Instant Fire-and-forget"));
System.Diagnostics.Debug.WriteLine("The job id is: " + id);
id = BackgroundJob.Enqueue<Tester>(y => y.SubmitJobToHangfire("RichardTest"));
System.Diagnostics.Debug.WriteLine("The job id is: " + id);
return "Done";
}
}
public class Tester
{
[Queue("tester")]
public void SubmitJobToHangfire(string testString)
{
System.Diagnostics.Debug.WriteLine("testString: " + testString);
}
}
}
So, I will see Instant Fire-and-forget
, but I will never see testString: RichardTest
.
Any help would be super appreciated. Thanks.