简体   繁体   中英

How to make WCF service run continuously in IIS?

I've written a small wcf service application which reads messages from msmq. And hosted the wcf service in IIS-7. THe issue is I can read the message only if I click on browse button from IIS. There is no client application which refers this service uri. I need wcf service to run automatically and continuously all the time.

Is it possible to run the WCF service hosted in IIS continuously without any user interaction ?

When you host anything in IIS,it always run continuously unless your site is idle.IIS has a default setting where the site is idle for more than 20 minutes,it will shutdown the site.This setting is at the application Pool advanced settings as shown below

应用程序池空闲超时

You can set Application Pool Idle time out to zero so that it never shuts down

Also wondering how exactly have you written the logic to pull the data from the MSMQ service.In case you have not looked into the details, Running a recurring background job is not straightforward in WCF or Asp.net .If you are using timer thread,it may not work all the time. if you are using something like hangfire ,then it fine .But you have to make sure that it can fine all the time and check all edge cases like this and this

So the take away is

if you need a background task, use a Windows Service instead.Or you use something like hangfire or this nuget and with IdletimeOut to 0 in corresponding Application Pool

Have you configured the application pool to be running continuously? This means at the least disabling all recycling mechanisms, setting idle timeout to 0, and setting Start Mode == Always.

You'd probably benefit from using the Application Initialization module to ensure the service remains activated all the time.

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