Sorry guys… just cant find it out…
I have this ASP Core web site, it’s a data mining portal doe a diamon exchange. Until today I was using Hangfire in my Web app without any problems, now I have new demands and I need to provide a lot of Job Processor. I really cant find a simple tutorial how-to enqueue a job to a console processor.
no 1… it’s really strange. what am I missing
If you’re on a Windows box, I’d recommend processing in a service over a console app as they are easier to maintain and monitor. Here’s the official documentation on running as a service: http://docs.hangfire.io/en/latest/background-processing/processing-jobs-in-windows-service.html
If you go this route, I would recommend checking out Topshelf so that you can essentially run a console app as a service.
thank you for the reply dear friend.
I know TopShelf, thank you for the recommendation.
I’ll need to stay with console app, but my question is how to enqueue the job in the web app.
Until now I used to do all the jobs in the background, running everything from the web site.
So I used this line to enqueue the job, I gave it the function name and parameters and everything worked.
BackgroundJob.Enqueue(() => HangfireBackgroundTasks.HangfireJob(jobData, JobCancellationToken.Null));
Now, how do I enqueue the job?? my processing function is not in this solution… tried to search for examples …
There are a few ways you can do this, but all of your actual processing logic will, obviously, need to be in whatever application executes the background server. You could extract out a project that has all of your processors and include that project in both your web solution and console solution. However, a better approach would be to interface things out and share the interfaces across the solutions. Then, use an IoC like autofac on the console app (background server processor) to inject the actual interface implementation.
There are a few examples of this sort of thing in the hangfire documentation and autofac documentation.