Open Closed

Abp Background Job #4918


User avatar
0
DominaTang created
  • ABP Framework version: v4.1
  • UI type: Angular
  • DB provider: EF Cor
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

After Enqueue a job request to JobManager, AbpBackgroundJobs table, that request IsAbandoned flag is set to 1. If add delay parameter to Enqueue method, say 3 minutes, Job record in AbpBackgroundJobs, the IsAbandoned value is 0, and three minutes later, the IsAbandoned value is 1

It seems that the JobManager can not locate the Job class successfully? How to job manager can locate the corresponding job to handle the parameter? I tried to add jobName attribute to EmailNotificationArgs class, but it doesn't work. There is exception in Log file neither.

"public class PartyCompleteEmailJob : AsyncBackgroundJob<EmailNotificationArgs>, ITransientDependency"


1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I don't quite understand what you mean. can you explain it in detail?

    public class TestAppService : MyProjectNameAppService
    {
        private readonly IBackgroundJobManager _backgroundJobManager;
    
        public TestAppService(IBackgroundJobManager backgroundJobManager)
        {
            _backgroundJobManager = backgroundJobManager;
        }
    
        public async Task SendDelayEmail()
        {
            await _backgroundJobManager.EnqueueAsync<EmailNotificationArgs>(
                new EmailNotificationArgs { Email = "test", Subject = "test", Body = "test" },
                delay: TimeSpan.FromMinutes(3));
        }
    }
    
    public class EmailNotificationArgs
    {
        public string Email { get; set; }
        public string Subject { get; set; }
        public string Body { get; set; }
    }
    
    public class PartyCompleteEmailJob : AsyncBackgroundJob<EmailNotificationArgs>, ITransientDependency
    {
        public override Task ExecuteAsync(EmailNotificationArgs args)
        {
            Logger.LogInformation("------------- Sending email to " + args.Email + " with subject " + args.Subject + " and body " +
                                  args.Body + "");
            return Task.CompletedTask;
        }
    }
    

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38