BEST
DEALS
OF THE
YEAR!
SAVE UP TO $3,000
24 NOV
1 DEC
00 Days
00 Hrs
00 Min
00 Sec
Open Closed

Camunda Worker in ABP.io #8001


User avatar
0
Karthigeyan created

Hi Team,

I have integrated Camunda workflow and created a class CamundaWorker which inherits BackgroundService of "Microsoft.Hosting", also added in the context service like below,

context.Services.AddHostedService<CamundaWorker>();

But if I try to call the other application service from CamundaWorker, it is throwing execption "EntityNotFoundException" where the tenant Id is not passed and it is not able to find the entity. How to register the above worker class to the multi-tenany.

Thanks.


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

    Hi,

    How to register the above worker class to the multi-tenany.

    You need to get all tenants first. You can try to use ADO.NET to get all tenants and register workers class to the multi-tenany

    SqlConnection connection = new(connectionString);
    
    var tenants = await connection....;
    
    foreach(var tenant in tenants)
    {
        context.Services.AddHostedService....
    }
    

    But there is a problem, When you add a new tenant, you need to restart the application.

    I recommend you to loop through all tenants in the worker

    public class CamundaWorker ....
    {
         public ......()
         {
             var tenants = await TenantRepository.GetListAsync();
             
             foreach(var tenant in tenants)
             {
                 using(CurrentTenant.Change(tenant.Id))
                 {
                      ... 
                 }
             }
         }
    }
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on November 20, 2025, 09:12
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.