0

I have been using Hang-fire in our project but had a question, Can i call a hangfire Recurring Job from an API?

For Example: http://devmyproject.com/projectname/recurring is the url for Hangfire web application to get recurring job. Now from my webApi project i want to call this Url and invoke a Job to run. Is this Possible?

Thanks

Arjun A
  • 131
  • 2
  • 3
  • 10

2 Answers2

1

In The HangFire Project i added an end points to make it an API to get the Requests and then run the Hangfire job. I added Fire and Forget Job to run the HangFire job.

Arjun A
  • 131
  • 2
  • 3
  • 10
0

Yes you can certainly perform hangfire functions by calling an API. Here is the function for creating a Hangfire job as listed on the front page of hangfire site.

RecurringJob.AddOrUpdate(
    () => Console.WriteLine("Recurring!"),
Cron.Daily);

The URL you call should be an endpoint which you can pass parameters to. Then if hangfire is set up correctly it should be like any other application.

rjustin
  • 1,399
  • 8
  • 19
  • Can i call from API to the Hang-fire Recurring Job? Example: MyWebAPI/Post/{firehangfire} -> this should call hangfire myRecurring Job. Can you provide me with example. – Arjun A Sep 14 '17 at 16:39
  • You will need some kind of API on the hangfire side to field the requests. I dont know the structure of your application but you will need an endpoint that accepts http requests on MyWebAPI/Post/{firehangfire} which should be on the same project as hangfire – rjustin Sep 14 '17 at 17:01