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

Enqueued method's parameters get deserialized multiple times

I am new to Hangfire and currently testing it out with a .Net6 API. I am trying to Enqueue the following method :
Hangfire.BackgroundJob.Enqueue<IDomainNotificationProcessor>(x => x.ProcessDomainEventNotificationAsync(domainEventNotification));
“ProcessDomainEventNotificationAsync” uses Mediatr to publish the “domainEventNotification” parameter. when Hangfire Server executes this job, multiple instances of the parameter which is of Type “OrderPlacedNotification” get created by a single Thread:


Until one of them is passed to the “ProcessDomainEventNotificationAsync” which handles it successfully.
When I open the dashboard and click on the “Succeeded” tab,
new instances of the parameter are created:

Whenever I re-click the succeeded tab, additional instances of the parameter keep getting created on their own without being passed to any method:
The dashboard shows that the job has been processed successfully only once.

Any help would be appreciated. Thanks!

Yes, arguments can be de-serialized multiple times – during processing, for displaying in the dashboard, etc. – it’s just de-serialization, e.g. converting from one representation into another without any meaningful action. So I’m afraid that notification shouldn’t be created in the JSON-related constructor.

1 Like