We left Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

How to identify source RecurringJob when deleting BackgroundJob

I need to cleanup PendingJobs on server start during a release of new code, so I’m running code taken from this thread: Is there a way to cancel all pending jobs in a named queue? · Issue #394 · HangfireIO/Hangfire · GitHub

I’m taking records returned by monitoringApi.EnqueuedJobs, getting a JobId from .Key, and then BackgroundJob.Delete()-ing it.
All good.

It would be really nice, though, to know What is getting deleted :sweat_smile:.
The JobId doesn’t mean much in the logs, so I’d love to be able to tie that JobId back to a RecurringTask Id/Key.

Is that possible?

Obviously I can imagine that some BackgroundJobs, might not have any associated RecurringTask, so I’d expect this to be “do this, and depending on the nature of the BackgroundJob you may or may not get a null / throw an Exception/ get an empty list.”