Make hangfire fire-and-forget job queue only work in given time period

107 Views Asked by At

I created a method to do some specific job and want to run this method only in specific time of a day (ex: between 00:00 - 03:00). I want this fire-and-forget job only works between this times of day.

I created a queue for that, and this kind of jobs will be added to this queue.

var options = new BackgroundJobServerOptions
{
    Queues = new[] { "alpha" }
};

app.UseHangfireServer(options);

[Queue("alpha")]
public void SendNotification(string email) { 
   NotificationService.SendNotificaton(email);
}

Is it possible to make this queue jobs are only enqueued and processed at given time period of day? I mean, i dont want this SendNotification method is processed at any other time except 00:00 - 03:00 period?

0

There are 0 best solutions below