HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.31k stars 1.69k forks source link

Setting job display name dynamically at point of queuing #2429

Open arynaq opened 1 month ago

arynaq commented 1 month ago

This is my dispatching to the queue

BackgroundJob.Enqueue<IMediator>( x => x.Send(new MyCommand(entity_id), cancellationToken));

This works just fine, the problem is that in the dashboard all jobs capture the expression method as name, and when something goes wrong I have to inspect each item in the dashboard to get its parameters.

image

Looking back there seemed to be a IDashboardJobNameProvider which got refactored into DisplayNameFunc in DashboardOptions. But consider this

endpoints.MapHangfireDashboard("/hangfire", new DashboardOptions {
            DisplayNameFunc = (DashboardContext context, Job job) => {

                // ??? neither the context nor the job has any property that could be used to get the job name
                // job.id?
                // context.PropertyBag?
                // job.PropertyBag?
                // anything?
            }
         });

Am I missing something? I love the framework and do understand the design choice behind not too much dynamic data, but this is a simple use case I have and I am stuck.

HernJer commented 1 month ago

You can use the Display Name attribute or use the Tags library (FaceIT.Hangfire.Tags).

image