2

We have a web app built in asp.net core 2.0 hosted on IIS. From this app we are invoking a console app which performs queued request from database.

Problem is that application is used by very less people so it and the console process performs long time taking processing. But this console app stops automatically when web application shuts down. From event log we get following output. (source: IIS AspNetCore module)

Sent shutdown HTTP message to process '3548' and received http status '202'.

We tried to set the web app's StartMode to always running in IIS application pool advanced setting. But still when no one is using the application after some time it stops.

Any solution?

Sid
  • 2,582
  • 4
  • 16
  • 20
  • “From this app we are invoking a console app which performs queued request from database" is not the right way. Instead, run the console app always and let your web app talk it via typical inter-process communication. – Lex Li Sep 12 '18 at 16:52

1 Answers1

0

You seem to be approaching the problem wrong. I would not invoke a console app from the Web app. Instead you should ideally create a back end service (e.g.: Windows Service with .NET Core) that periodically monitors the queue table of yours and incrementally does stuff with it.

This will make your code modular (ref. SOLID principles). It will also alleviate the problem you are having with running your console app in the same process as your web app.

adityap
  • 329
  • 1
  • 10
  • I have to start the console app (or service) as soon as it is triggered from Web UI. Also once it is running, there may come additional items in queue. So periodically checking will not work. Also there may be case when for weeks there will be no request from UI, so running console app in backend always is not required. – Sid Sep 12 '18 at 18:55
  • 1
    A service running with no work to do should not take any significant resources if done correctly – Mike Sep 12 '18 at 19:52
  • Sid - What Mike said. Plus, I do not understand why periodic checking will not work in the scenario you mentioned. In fact to the contrary, that's exactly what such services are meant to do. Of course, when building this service you would want to give due regards to the locking/concurrency issues with the access and processing of Queue table. – adityap Sep 12 '18 at 20:51
  • In your original question you mentioned that this console app of yours does a time taking process. In such scenarios, you could have points in the processing where you could check the queue again to include any new records that came in and include them too. Alternatively you could start the processing all over again (depending on which scenario ends being faster for you) if you see updates in Queue. – adityap Sep 12 '18 at 20:53