Open Closed

Run Hangfire on multiple instances #2296


User avatar
0
yousef.h85@gmail.com created

Hi,

We are building a Blazor server app (Multi-Tenancy and MongoDB ) and we need to use Hangfire for backgrounds jobs for all Tenants.

We have two questions : 1 - How we can implement a hangfire server in an isolated Abp app and run this app on multiple instances? 2- How it can handle and access the tenant databases?

  • ABP Framework version: v5
  • UI type: Blazor Server
  • DB provider: MongoDB

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

    Hi,

    1 - How we can implement a hangfire server in an isolated Abp app and run this app on multiple instances?

    Hangfire natively supports multi-instance servers, you only need to deploy multiple application instances.

    2- How it can handle and access the tenant databases?

    Example:

    var tenants = await _tenantRepository.GetListAsync();
    
    foreach(var tenant in tenants)
    {
       using(CurrentTenant.Change(tenant.Id))
       {
           //handle and access the tenant databases...
       }
    } 
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15