HangfireIO / HangfireIO/Hangfire

Enqueue self in OnPerformed in IServerFilter?

Open
#623 0 comments 0 reactions 0 assignees View on GitHub
t: question
Dominant language
C#
Stars
10.1k
Forks
1.8k
Avg merge
1h 19m
Merged PRs (30d)
1

Description

I really enjoy Hangfire as a job scheduler.
I am currently adapting the https://gist.github.com/odinserj/a8332a3f486773baa009 gist. What I want, is that the current job will conditionally respawn itself as a new job in the queue in the OnPerformed method. Is there already a way to do this?

Maybe something like this:

```
public void OnPerformed(PerformedContext filterContext)
{
if (filterContext.Exception == null || filterContext.ExceptionHandled)
{
if (RemoveFingerprintAndReschedule(filterContext.Connection, filterContext.Job))
{
var id = filterContext.BackgroundJob.Id;
BackgroundJob.Enqueue(id); // This is currrently not an available overload
};
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.