Skip to content
Extension of the Hangfire to delete jobs that are not in the code
Branch: master
Clone or download
Latest commit 35af299 Jul 1, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github style refactor Jul 1, 2019
docs/images/readme
src
.gitignore Initial commit Jun 12, 2019
Hangfire.RecurringJobCleanUpManager.sln
LICENSE Initial commit Jun 12, 2019
README.md Update README.md Jun 14, 2019

README.md

Hangfire.RecurringJobCleanUpManager

Hangfire extension to delete jobs that have been removed from configuration code.

Objectives

  • Delete jobs that have been removed from configuration code.
  • Achieve the former objective in a simple/streamlined implementation.

Current situation

When first configuring a new job on Hangfire, there is a synchronization between the job configuration on code and the job definitions persisted on database. scenario

Then, when removing a job from your code ... Code remove

... the corresponding job definition is not removed from the database. No definition remove

Solution

Add a manager that removes jobs no longer defined in code but still persisted in the database, restoring synchronization. New manager

Example of use

var recurringJobCleanUp = new RecurringJobCleanUpManager(recurringJobManager)
{
    EnforceRecurringJob.Create<StoreBookings>("StoreBookings1", bookings => bookings.Execute(),Hangfire.Cron.Minutely()),
    EnforceRecurringJob.Create<StoreBookings>("StoreBookings2", bookings => bookings.Execute(),Hangfire.Cron.Minutely())
};

recurringJobCleanUp.AddUpdateDeleteJobs();
You can’t perform that action at this time.