WCF net.msmq服务自动激活 [英] WCF net.msmq service auto activation

查看:123
本文介绍了WCF net.msmq服务自动激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个WCF服务,它们使用net.msmq协议并在IIS 7中托管。

我的问题是,当队列中出现新消息时,服务不会激活。我们必须在开始接收任何消息之前先手动浏览服务。



有没有办法自动激活这些服务?



提前感谢您提供任何帮助。

解决方案

这可以通过.Net 4和IIS7.5的组合来实现。



首先你需要自动启动应用程序池。



为应用程序池(IIS 7)配置自动启动 [ ^ ]



然后你需要将应用程序配置为自动启动:



自动启动ASP.NET应用程序(VS 2010和.NET 4.0系列) ) [ ^ ]



如果您无法访问这些组件,则需要通过其他方式使应用程序保持活动状态。例如Windows服务中的以下代码片段:



 WebClient refresh =  new  WebClient(); 
尝试 {
refresh.UploadString( http://www.website.com/ string .Empty);
}
catch (例外情况){
// < span class =code-comment> snip ...
}
finally {
refresh.Dispose( );
}





我从这篇文章中得到的,讨论了生存问题。



保留您的网站活着(不要让IIS回收你的网站)! [ ^ ]



IIS应用程序上有许多设置控制工人流程回收的池。



了解这些也可以帮助减少应用程序关闭的次数。



应用程序池的回收设置 [ ^ ]



虽然你想要我的建议。我完全放弃了IIS并开发了一个自托管的WCF应用程序。然后问题就会消失。



如何to:在托管应用程序中托管WCF服务 [ ^ ]


I have two WCF services, which use the net.msmq protocol and hosted in IIS 7.
My problem is that the services do not activate when a new message appears on the queue. We have to manually browse the services first before they start picking up any messages.

Is there any way to auto activate these services?

Thanks in advance for any help.

解决方案

This is do-able with the combination of .Net 4 and IIS7.5.

First you need to auto start the application pool.

Configure Automatic Startup for an Application Pool (IIS 7)[^]

Then you need to configure the application to auto start:

Auto-Start ASP.NET Applications (VS 2010 and .NET 4.0 Series)[^]

If you don't have access to these components then you'll be required to keep the application alive by other means. Such as the following code snippet in a windows service:

WebClient refresh = new WebClient();
try {
    refresh.UploadString("http://www.website.com/", string.Empty);
}
catch (Exception ex) {
    //snip...
}
finally {
    refresh.Dispose();
}



Which I got from this article, discussing the keep alive problem.

Keep Your Website Alive (Don’t Let IIS Recycle Your Website)![^]

There are a number of settings on the IIS application pool which control recycling of the worker processes.

Understanding these can also help reduce the number of times the application shuts down.

Recycling Settings for an Application Pool[^]

Although if you want my advice. I'd completely drop IIS and develop a self hosted WCF application. Then the problem will just disappear.

How to: Host a WCF Service in a Managed Application[^]


这篇关于WCF net.msmq服务自动激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆