1

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 ?

user2995902
  • 49
  • 1
  • 8

2 Answers2

2

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

Application Pool Idle Timeout

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

Rohith
  • 5,527
  • 3
  • 27
  • 31
  • Thanks for the response. I was working with Microsoft support it looks like we can host the wcf service in 3 ways. 1. Initialization Module (IIS 8 or above). 2. Using Task Scheduler(specific exe project). 3. Power Shell We have both types of client who are using IIS7 & 8. Not sure what is the recommended way for IIS7. As of now I'm not using any threading mechanism. Also, I never worked on hangfire. I will go through your article and will see. – user2995902 Jun 29 '17 at 18:15
1

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.

tomasr
  • 13,683
  • 3
  • 38
  • 30
  • Thank you. As per your suggestion I tried Application Initialization module in IIS8 and changed the Advanced setting's Idle timeout to 0 and start mode to always. Now after recycling it reads the message immediately. Is there is any other configuration I need to change when I host WCF service in IIS8 or above. I am just trying to figure out the standard procedures to follow. I didn't find any article on this. – user2995902 Jun 29 '17 at 18:20