Is there any way to expose Hangfire Job as Service? I wanted some of my hangfire jobs to be triggered from outside of hangfire project.
Asked
Active
Viewed 201 times
1 Answers
0
After some analysis we are able to achieve this. since it will be useful to someone i am sharing here.
I am using .netcore razor pages in hangfire project.
Create normal web api controller inside hangfire project. (.addmvc() function should be there in startup)
Add endpoint inside api.
[HttpGet("RecurringJob")] public void TriggerRecurringJob(string jobId) { RecurringJob.AddOrUpdate<IJobScheduler>( JobId, task => task.ScheduleAnyJob(), "jobCron", timeZone: TimeZone.Local); RecurringJob.Trigger(jobId); }
Now you can run expose and consume as normal api inside hangfire project itself. If you require any authentication then you can implement filters.

Vetrivel mp
- 1,214
- 1
- 14
- 29