Open Closed

Override default values for a specific background job #8792


User avatar
0
stephanobalbinot created
  • ABP Framework version: v8.3.4
  • UI Type: Angular
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Currently I'm using the default background job manager and have this configuration for background jobs in my application.

But there's a specific background job that I do not want to retry in case of failure. How can I override default values just for this job?


1 Answer(s)
  • User Avatar
    1
    berkansasmaz created
    Support Team .NET Developer

    You can't set different retry count for each job with DefaultBackgroundJobManager. If you want a custom implementation, you can replace DefaultBackgroundJobManager with your CustomBackgroundJobManager. So it's open-source: https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/DefaultBackgroundJobManager.cs

    [Dependency(ReplaceServices = true)]
    public class CustomBackgroundJobManager : DefaultBackgroundJobManager
    {
        public CustomBackgroundJobManager(IClock clock, IBackgroundJobSerializer serializer, IBackgroundJobStore store, IGuidGenerator guidGenerator) : base(clock, serializer, store, guidGenerator)
        {
        }
    
        protected override Task<Guid> EnqueueAsync(string jobName, object args, BackgroundJobPriority priority = BackgroundJobPriority.Normal, TimeSpan? delay = null)
        {
            // Custom implementation
            throw new NotImplementedException();
        }
    }
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 20, 2025, 18:00