简体   繁体   中英

Quartz.NET: in the Asp.Net Web vs Console Application

I need to run 4 background gobs for cleaning temp files and proccessing some files. I have chosen Quart.net for the job.

I have a Asp.Net website, which accepts uploading files that will be processed by the Quartz Jobs at night.

First i thought about making a console application for the Quartz jobs, keeping the website and the jobs totally decoupled.

But then, i've seen that i will need some config values (connectionstring and paths to files) that are on the asp.net web.config. So a question came to my mind:

Should i run the jobs through the asp.net instance or should i do this on a console application?

Furthermore, i want that when the Quartz jobs start running, the website show a special page (like "We are processing the files...).

What i care the most is the performance , i don't want the website to be affected by the Quartz jobs, neither the jobs' performance affected by the website.

So, what should i do? Have you done something like this and can give me an advice?

Should i run the jobs through the asp.net instance or should i do this on a console application?

If you want to have to manually trigger them each night, sure. But a console application using the host system's task scheduler seems like a more automated solution. A web application is more of a request/response system, it's not really suited for periodic or long-running actions. Scheduling some sort of background operation on the host, such as a scheduled console application or a windows service, would serve that purpose better.

Note that if it truly needs to be unattended and run even when there's nobody logged in to the server console, a windows service may be a more ideal approach than a console application.

i've seen that i will need some config values (connectionstring and paths to files) that are on the asp.net web.config

Console application have App.config files which serve the same purpose. You can use that.

i want that when the Quartz jobs start running, the website show a special page

You definitely want to keep the two de-coupled. But you may be able to accomplish this easily enough. Maybe have some sort of status flag in the database which indicates if any particular record is "currently being processed". The website can simply look for any records with that flag when a page loads and display that message.

There are likely a couple of different ways to synchronize status here, it doesn't really matter what you choose. What does matter is that the systems remain decoupled and that any status which is statically persisted is handled somewhat carefully to avoid an errant process from leaving an incorrect status. (For example, a background task sets a status of "processing" and then fails in some way. The website would forever indicate that it's processing.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM