Skip to content

Hangfire integration in BackgroundJobs #16665

Answered by xorinzor
xorinzor asked this question in Q&A
Discussion options

You must be logged in to vote

Overriding the GetQueueName method from HangfireBackgroundJobManager using the code below got me 1 step further. It now enqueues the job in Hangfire (using the native BackgroundJobname attribute as defined at the Job Args instead of the Queue attribute in the Job itself.

public class CustomHangfireBackgroundJobManager : HangfireBackgroundJobManager
{
    public CustomHangfireBackgroundJobManager(IOptions<AbpBackgroundJobOptions> options) : base(options)
    {
    }
    
    protected override string GetQueueName(Type argsType)
    {
        return BackgroundJobNameAttribute.GetName(argsType);
    }
}

Make sure to also replace this class in DI

context.Services.Replace(ServiceDescriptor.Tr…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@xorinzor
Comment options

Answer selected by xorinzor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant