Hello,
i am still doin trials on my own while tryin to find the recommended practical life cycle for backgroundjobserver, few background on my app :
each tenant have their own database, and the connectionstring for their account is stored in one master database,
and what i am trying to do is :
- after logging in, i create several BackgroundJobServer that have unique queues for their own type of jobs
- when i am enqueueing a job, i do :
- var sqlStorage = new SqlServerStorage(storedConnString);
- var client = new BackgroundJobClient(sqlStorage);
- client.enqueue the job
- for recurring jobs, i do :
- RecurringJobManager recurJobM = new RecurringJobManager(sqlStorage);
- RecurringJobOptions recurJobOpt = new RecurringJobOptions()
{
QueueName = “queue_name_for_recurrin_server”
}; - recurJobM.AddOrUpdate(“recurring_name”,method,recurJobOpt)
- now, my problem is, the recurring is intended to stop working once the user logout, and i tried to do this by removing the server by doing this :
- var sqlStorage = new SqlServerStorage(storedConnString);
- var monitoringApi = sqlStorage.GetMonitoringApi();
- var serverList = monitoringApi.Servers();
- foreach (var server in serverList)
{
var serverConnection = sqlStorage.GetConnection();
serverConnection.RemoveServer(server.Name);
}
from hangfire.server table i found out that :
the server is removed, but then reappear again in seconds and continues the recurring jobs,
why did this happen ?
i am also open for other recommended ways to handle BackgroundJobServer life cycle,
as i am new in this