Base solution for your next web application
Open Closed

Working with background jobs. #3163


User avatar
0
codenewa created

From the documentation, it seems that the background jobs are retried for up to 2 days which is the default timeout.

  1. Is there a way to cancel the job in case of exceptions?
  2. How do I get the identifier for the current BackgroundJob<TJobArgs> which is being executed?
  3. Also, how can I push the exceptions from a background job into the audit logs?

4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    1. Is there a way to cancel the job in case of exceptions? I haven't tried it but you can set BackgroundJobInfo.DefaultWaitFactor = 0; In that case all jobs will be abondened when they fail.

    2. How do I get the identifier for the current BackgroundJob<TJobArgs> which is being executed? This is not at the moment, you can create an issue on github if you like, here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues">https://github.com/aspnetboilerplate/as ... ate/issues</a>.

    3. Also, how can I push the exceptions from a background job into the audit logs? Have you tried this <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Audit-Logging#DocEnableDisableByAttrs">https://aspnetboilerplate.com/Pages/Doc ... bleByAttrs</a> ?

    Thanks.

  • User Avatar
    0
    codenewa created

    Thanks I'll try out the BackgroundJobInfo.DefaultWaitFactor = 0 for single attempt jobs.

    For the Auditing, I did take a look at it but since it needed the tenantId and userid, I didn't think that it'd work. I was not sure where the background job would produce those values.

  • User Avatar
    0
    codenewa created

    The [Audited] attribute worked. The username, client, ipaddress and browser are null but that would be as expected.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Great :)