Open Closed

[BackgroundJobName("emails")] ignored when using hangfire #689


User avatar
0
BassaSolutions created
  • ABP Framework version: v3.3.1

Documentation https://docs.abp.io/en/abp/latest/Background-Jobs says that the jobsname can be set via an argument: [BackgroundJobName("emails")]

But in Hangfire, the jobname is then still "HangfireJobExecutionAdapter<EmailArgs>.Execute" instead of "emails".

How can the jobname be set?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

5 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Add the following code to your module:

    context.Services.AddTransient(serviceProvider =>
    {
        return new DashboardOptions
        {
            DisplayNameFunc = (jobContext, job) =>
            {
                var jobType = serviceProvider.GetRequiredService<IOptions<AbpBackgroundJobOptions>>().Value
                    .GetJob(job.Args.First().GetType());
                return jobType.JobName;
            }
        };
    });
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    BassaSolutions created

    I added it,the defined job name is still not displayed.

    I put it directly after

       // Configure Hangfire
        context.Services.AddHangfire(config =>
        {
            config.UseSqlServerStorage(configuration.GetConnectionString("Default"));
        });
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Can you share some screenshots?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    See https://github.com/abpframework/abp/pull/6701

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    BassaSolutions created

    I found the solution, it had to be added directly into useHangfireDashboard:

      var backgroundJobOptions =
                    context.ServiceProvider.GetRequiredService<IOptions<AbpBackgroundJobOptions>>().Value;
       app.UseHangfireDashboard("/jobs", new DashboardOptions
        {
            DashboardTitle = "MyProject Background Jobs",
            DisplayNameFunc = (jobContext, job) =>
            {
                var jobType = job.Args.First().GetType();
                var abpJobType = backgroundJobOptions.GetJob(jobType);
                return abpJobType.JobName;
            }
        });
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.