Base solution for your next web application
Open Closed

Setting the JobId for a scheduled job #4084


User avatar
0
sh0knah created

I need to be able to set the JobId when I schedule a one-time or recurring job. I'm allowing users to schedule jobs and if they change the schedule or delete the job, I need to be able to update or remove the original job. (These could be reminders or scheduled reports, etc.)

Hangfire seems to support this with the following syntax:

RecurringJob.AddOrUpdate("some-id", () => Console.WriteLine(), Cron.Hourly);

I'd be happy to use the Hangfire API directly, if someone could point me to some information on how to reference it in AspNetZero. I've completed the Hangfire integration steps. I can create Background Jobs through the ABP interface. And I can access the Hangfire dashboard and follow the progress of my jobs, which are all running correctly. But I don't know how to access the native Hangfire functionality so that I can set a JobId on a job.

Any help would be greatly appreciated. I can't seem to find anything on this anywhere, other than this one statement in the ABP Hangfire Integration document: "Thus, your code will be independent of Hangfire. But, if you like, you can directly use Hangfire's API also."

Thank you!


2 Answer(s)
  • User Avatar
    0
    alirizaadiyahsi created

    Hi @Sh0knah,

    Abp.HangFire.AspNetCore is already referenced in AspNetZero. You can use it directly. After you apply this step: <a class="postlink" href="https://aspnetzero.com/Documents/Development-Guide-Core#background-jobs-and-hangfire">https://aspnetzero.com/Documents/Develo ... d-hangfire</a> then you can also use Hangfire API. Just write hangfire code.

  • User Avatar
    0
    sh0knah created

    Awesome. Thank you!

    I don't know why that didn't occur to me. But it's working great.