Open Closed

AsyncBackgroundJobs #1628


User avatar
0
Qusai created

Dears,

i tried to Implement backgroundjobs in my solution , i did exactly like the documentation said but still it didn't work.

i want the background job to work on startup knowing that i'm using microservices archetichture.

so can you please tell me how to make it work on startup when i run the microservice its implemented in.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

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

    Hi,

    i did exactly like the documentation said but still it didn't work.

    Can you provide steps to reproduce? thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Qusai created

    hi,

    i did all whats in this documentation https://docs.abp.io/en/abp/latest/Background-Jobs

    and changed options.IsJobExecutionEnabled to true

    Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = false; //Disables job execution });

    but still its not working when i run the microservice.

    so i want to know whats the right way to implement it and what to exactly do to make it work on startup.

    and can you also please tell me how it works and what is it usually used for ? just to know if its the right thing for what i need or not

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    1
    liangshiwei created
    Fullstack Developer

    Hi,

    Can I check it remotely?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Qusai created

    yes , should i send you a zoom link ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Please send an email to me. shiwei.liang@volosoft.com

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Qusai created

    the email is not correct

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    HI,

    Sorry, should be shiwei.liang@volosoft.com

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Resolved. You need to queue a job item: https://docs.abp.io/en/abp/latest/Background-Jobs#queue-a-job-item

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Qusai created

    one more thing , when we run a backgroundjob how can we determine the Tenant Connectionstring as we are using seperate databases per tenant.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Use CurrentTenant.Change for per tenant : https://docs.abp.io/en/abp/latest/Multi-Tenancy#change-the-current-tenant

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Qusai created

    thanks , also in my background job i use InsertManyAsync , but if the records are more than 10K it does not insert them and it returns TimeOut , and if the records are 10K or less it inserts them but does not return a result.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    You can try use https://github.com/borisdj/EFCore.BulkExtensions

    I think your main problem has been resolved, so will close the ticket.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Qusai created

    but why InsertManyAsync is not working right ? and EFCore.BulkExtensions only work for Microsoft Sql and SQLLite, i use PostgreSQL.

    and yes my main problem has been resolved but all of these problems are connected, all in the same background job.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    EFCore.BulkExtensions only work for Microsoft Sql and SQLLite, i use PostgreSQL.

    You can use commercial ef core extension: https://entityframework-extensions.net/bulk-insert, this is actually not related to ABP but EF Core.

    but why InsertManyAsync is not working

    This is no magic, InsertManyAsync just use the native API of EF Core, you will also get the problem without ABP : ) .

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Qusai created

    can i do more than one queue for the same job ?

    and the BackGround worker does it execute (DoWorkAsync) everytime the timer starts ? lets say im executing something that will take alot of time and the timer is set to 1 minute , will it still execute the (DoWorkAsync) ? or will it wait until the first execution is done and then count another 1 minute ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @Qusai,

    and the BackGround worker does it execute (DoWorkAsync) everytime the timer starts ? lets say im executing something that will take alot of time and the timer is set to 1 minute , will it still execute the (DoWorkAsync) ? or will it wait until the first execution is done and then count another 1 minute ?

    It waits until the first execution is done but does not count another 1 minute again. For example: Just assume you set your timer as 10 minute and it first called at 1.10pm, and assume your job finished at 1.22pm (took 12minutes, more than our period). The counter will not count from that point it will only count extra 8 minutes to complete your period (10 minutes) and run your worker.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Qusai created

    but for some reason in my case it starts again before it finishes the first execution , i logged everything , and when i check it starts another execution before the first one ends .

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Qusai created

    can you please help with the problem i'm having ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    alper created
    Support Team Director

    if you don't want to overlap the jobs, there's a very basic solution; add a static variable bool IsTheLastJobStillRunning = false then check this flag if it's true then return else set this true do your work set this false.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
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.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.