简体   繁体   English

如何在IIS中连续运行WCF服务?

[英]How to make WCF service run continuously in IIS?

I've written a small wcf service application which reads messages from msmq. 我写了一个小的wcf服务应用程序,它从msmq读取消息。 And hosted the wcf service in IIS-7. 并在IIS-7中托管了wcf服务。 THe issue is I can read the message only if I click on browse button from IIS. 问题是我只有在点击IIS中的浏览按钮时才能阅读该消息。 There is no client application which refers this service uri. 没有客户端应用程序引用此服务uri。 I need wcf service to run automatically and continuously all the time. 我需要wcf服务一直自动运行。

Is it possible to run the WCF service hosted in IIS continuously without any user interaction ? 是否可以在没有任何用户交互的情况下连续运行IIS中托管的WCF服务?

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 当您在IIS中托管任何内容时,它总是连续运行,除非您的站点处于空闲状态.IIS有一个默认设置,其中站点空闲超过20分钟,它将关闭站点。此设置位于应用程序池高级设置,如图所示下面

应用程序池空闲超时

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. 还想知道你是如何编写从MSMQ服务中提取数据的逻辑。如果你没有查看详细信息,在WCF或Asp.net中运行定期后台作业并不简单。如果你使用的是计时器线程,它可能不会一直有效。 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 如果你需要一个后台任务,使用Windows服务instead.Or你使用类似迟发型本的NuGet在相应的应用程序池,并与IDLETIMEOUT 0

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. 这意味着至少禁用所有回收机制,将空闲超时设置为0,并设置启动模式==始终。

You'd probably benefit from using the Application Initialization module to ensure the service remains activated all the time. 您可能会受益于使用应用程序初始化模块来确保服务始终保持激活状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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