Open Closed

Background jobs not executing in hangfire #8180


User avatar
0
rcalv002 created
  • Template: app
  • Abp version: 8.3.2
  • Created ABP Studio Version: 0.9.2
  • Tiered: No
  • UI Framework: blazor-server
  • Theme: leptonx
  • Theme Style: system
  • Database Provider: ef
  • Database Management System: sqlserver
  • Separate Tenant Schema: Yes
  • Mobile Framework: maui
  • Public Website: Yes
  • Optional Modules:
    • GDPR
    • TextTemplateManagement
    • LanguageManagement
    • AuditLogging
    • SaaS
    • OpenIddictAdmin
  • Steps to reproduce the issue:

Created app solution, and included an existing module (if I run the module directly in its own solution everything works well)

The module provides some functionality to receive api call and eventually queue up a job in the system which goes to hangfire (this works on module host)

When using this in app solution, the background job is executed ( i can see the api calls that this background job makes going out) but nothing ends up in hangfire, i believe it is executing in the built in default in mem implementation instead of hangfire.

My app module has the same version of hangfire and hangfire.sqlserver installed as module, which are in sync for abp 8.3.2 and is decorated with

typeof(AbpBackgroundJobsHangfireModule),
typeof(AbpBackgroundJobsModule)

in configureservices


 context.Services.AddHangfire(config =>
 {
     config.UseSqlServerStorage(configuration.GetConnectionString("Default"));
 });

 Configure<AbpHangfireOptions>(options =>
 {
     options.ServerOptions = new BackgroundJobServerOptions { Queues = new[] { DocusignConstants.DocusignQueue, "default" } };
 });
 
 Configure<AbpBackgroundJobWorkerOptions>(options =>
 {
     options.DefaultTimeout = 864000; //10 days (as seconds)
 });
 

in OnApplicationInitialization app.UseAbpHangfireDashboard("/hangfire", options => { options.AsyncAuthorization = new[] { new AbpHangfireAuthorizationFilter(enableTenant: true) }; });

While i can log in and see the dashboard, it never receives jobs.


13 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi Can you try to inject the IBackgroundJobManager to see the service type?

    Or you can share a project via https://wetransfer.com/ that can reproduce the problem.

    liming.ma@volosoft.com

    Thanks

  • User Avatar
    0
    rcalv002 created

    Mailed you

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ok, I will check it asap. Thanks

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I can't build your solution.

    Can you share a simple project?

    Thanks.

    These projects can't be found.

    <ProjectReference Include="../../../../Modules/Cns.Modules.Docusign/src/Cns.Modules.Docusign.Blazor/Cns.Modules.Docusign.Blazor.csproj" />

    
    <ProjectReference Include="../../../../Modules/Cns.Modules.Docusign/src/Cns.Modules.Docusign.Blazor.Server/Cns.Modules.Docusign.Blazor.Server.csproj" />
    
    
  • User Avatar
    0
    rcalv002 created

    I reshared projects with you

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Try to add context.Services.AddAssemblyOf<AbpBackgroundJobsHangfireModule>(); in your blazor project.

  • User Avatar
    0
    rcalv002 created

    I added this and i can see entry in debug log during project startup regarding hangfire. two questions

    1. After adding this, project just hangs on start up and then stops. This appears in the log
    Hangfire.SqlServer.SqlServerObjectsInstaller: Information: Hangfire SQL objects installed.
    Hangfire.BackgroundJobServer: Information: Starting Hangfire Server using job storage: 'SQL Server: (LocalDb)\MSSQLLocalDB@Cloudapps'
    Hangfire.BackgroundJobServer: Information: Using the following options for SQL Server job storage: Queue poll interval: 00:00:00.
    Hangfire.BackgroundJobServer: Information: Using the following options for Hangfire Server:
        Worker count: 20
        Listening queues: 'docusignsignatures', 'default'
        Shutdown timeout: 00:00:15
        Schedule polling interval: 00:00:15
    
    1. I've never had to add this before in any project, is this a new requirement? is it documented?
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    1.

    It works on my machine. I'm using the SQL Server from docker.(localhost)

    Please share full logs.txt file in your computer.

    2. There is something wrong with project dependencies, I'm researching the real reason

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You shouldn't depend on hangfire in your module.

    Module project shouldn't depend on any implemented module.

  • User Avatar
    0
    rcalv002 created

    as you can see our module solution comes from the previous abp design of modules where there were the **src **projects and the several **host **projects in the module solution. to completely develop and test the module we use the host solution as we would an "application" solution. therefore the module and host have the dependencies we plan to use once we integrate our module into any other app solution. for example this module can be integrated to 3 4 5 other app solutions (at least that was the idea with modules right?)

    I see in the latest version of solutions generated now by abp studio (since we can no longer generate anything in suite), creation of module doesnt have any host project and its just library projects for app project, but that means usability amongst other app projects is out of the question?

    Either way, if you're saying from now on our module projects cannot use already implemented modules from abp, then how do we code functionality in our modules that consumes that? for example the module provides all of the functionality related to docusign, like the app services that are exposed, events that are triggered and jobs that are handled, not the application project the application solution will bring in other modules that provide their respective functionality like this..

    Could you provide a process or flow of how we should develop these modules to make sure they don't clash?

    Also, could you provide a process flow for how you found the root problem in this ticket? It will help us with our troubleshooting before opening tickets in the future.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The module should be abstract, it can depend on the Volo.Abp.BackgroundJobs.Abstractions or Volo.Abp.BackgroundJobs module.

    Then, use hangfire to replace it in your application.

    So that your application can use its preferred implementation(hangfire or Quartz)

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I check the module depend order in logs to find the problem.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    :)

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