Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Way to delay hangfire job processing until module init? #5393


User avatar
0
rmorris created

Using the ABP background job config settings during preinit to use hangfire is fine, there's a minor annoyance at restart however where jobs that were in the queue will fail until the IoC container registration in initialize. Is there a good way to prevent the hangfire server from processing until then?


3 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi @rmorris, base on my understanding, background job is resume in module PostInitialize()

    public override void PostInitialize()
    {
        // more code
        if (Configuration.BackgroundJobs.IsJobExecutionEnabled)
        {
            var workerManager = IocManager.Resolve<IBackgroundWorkerManager>();
            workerManager.Start();
            workerManager.Add(IocManager.Resolve<IBackgroundJobManager>());
        }
    }
    

    See <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp/AbpKernelModule.cs#L91">https://github.com/aspnetboilerplate/as ... ule.cs#L91</a>

    IoC container registration in initialize

    Can you explain more on this?

  • User Avatar
    0
    rmorris created

    @ryancyq, the jobs were failing due to my job's service being injected with a NullObjectMapper so I was just assuming that was the case, however looks like my worker module is calling the RegisterAssemblyByConvention method off the IocManager before the jobs start failing.

  • User Avatar
    0
    ryancyq created
    Support Team

    I see. Is your ObjectMapper property injected?