Hi
We have 2 APIs that have nothing in common running Hangfire, but both APIs and Hangfire use the same database.
The APIs have their own schemas but the two Hangfire instances are using the same tables etc.
We are creating our background job servers the following way
backgroundJobServer = new BackgroundJobServer(new BackgroundJobServerOptions
{
Queues = new [] { QueueName }
});
Where each instance have their own QueueName
e.g: "Q1"
and "Q2"
.
Jobs are scheduled the following way
RecurringJob.AddOrUpdate<IService>("J1", s => s.DoJob(), Cron.Weekly(DayOfWeek.Monday, 01), TimeZoneInfo.Local, QueueName);
On top of that the method invoked on the service is also decorated with the [QueueAttribute]
, if not requeue through the web interface queues the job on the default queue.
public interface IService
{
[Queue(HangfireConfig.QueueName)]
Task DoJob();
}
Here is the conundrum
API1
HF1
Q1
J1
API2
HF2
Q2
J2
As you can see Iv tried to illustrate two APIs having their own Hangfire (HF) instances running with their own specified queues Q1 and Q2 where J1 is scheduled in Q1 and J2 is scheduled on Q2.
Still the HF2 instance tried to schedule the J1 job that should only run on the Q1 queue which HF2 is not supposed to run and vice versa by the HF1 instance.
This results in the following warning being written to the log Could not load file or assembly 'My.Service.API, Version=2018.3.5.20551, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
which is perfectly understandable as it doesn’t have the dll… But I dont want the HF1 instance to bother with HF2’s queues and jobs and vice versa, how do I configure them to only care about their own queues and jobs?