I have a web app that uses Hangfire to enqueue background jobs and set up recurring jobs. It works great.
However, I need to start processing incoming events from an external service. This service sends me events with unique identifiers. If my app doesn’t respond in time, the external service might retry the event.
In order to handle these events, I’d like to do something like this:
BackgroundJob.Enqueue(() => HandleEvent(event), event.UniqueIdentifier);
And let Hangfire handle ensuring that my HandleEvent
call is not called twice for the same event. Is there a way to do that?
Right now, it looks like the only way to do that is for my app to keep track of the event IDs and only enqueue a task when the event id is unique.