Hello: I am new to queuing background jobs and am unclear of the lifetime of such jobs. In my case, I would like to have a background job created that will be responsible for creating and sending a PDF file. The code for this job exists in a ASP.NET WebAPI controller that is called from another ASP.NET MVC website. All aspects of this are working, i.e. calling the WebAPI Controller routine, passing in the required variables, and then calling the background job. For example:
- Have a WebApi function called SendPDF which takes in three string params.
- I create an instance of the helper routine.
- I then call the background job, id = BackgroundJob.Enqueue(() => SendDocument.Send(value1, value2, value3);
In step (3) it seems as though I am actually doing two things; the first I creating the background job itself and the second is using this background job. When this job completes, what remains as a result of step (3), i.e. does a queue still exist for reuse? What if I called SendPDF 100 times, back to back? Does only one background job get created to handle the 99 subsequent calls or do I need to delete each queue, or call this queue by id to prevent 100 background jobs from being created and persisted?
In short, my disconnect is not understanding the background job itself, and the method(s) which use it. My concern is managing these jobs properly thru code, so one background job record/instance of type SendDocument.Send(…) does not end up becoming many and that I am properly reusing this background job to send my created pdf files via email.