在Web服务独立的线程它完成后, [英] Separate threads in a web service after it's completed

查看:244
本文介绍了在Web服务独立的线程它完成后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果这一直是我的歉意问过了,这是.NET 2.0 ASMX Web服务,再次表示歉意= D

If this has been asked before my apologies, and this is .NET 2.0 ASMX Web services, again my apologies =D

一个.NET应用程序,只有公开网站服务。每天负荷约10万条信息的多个IIS服务器之间的平衡。每个收到的消息是XML和传出消息的XML。 (XMLELEMENT)(我们有类固醇运行仡服务器)。

A .NET Application that only exposes web services. Roughly 10 million messages per day load balanced between multiple IIS Servers. Each incoming messages is XML, and an outgoing message is XML. (XMLElement) (we have beefy servers that run on steroids).

我有一个SLA,所有的消息都在X秒处理了。

I have a SLA that all messages are processed in under X Seconds.

一个功能,联方法,在此过程中现在正在10-20秒,要求对每一项交易,然而不是关键的,它发生在web服务返回结果前。正因为如此我做了一个建议,把它扔到另一个线程,但现在意识到我的话和渴望开发商在他们身后可能还没有完全想通这一点。

One function, Linking Methods, in the process is now taking 10-20 seconds, it is required for every transaction, however is not critical that it happens before the web service returns the results. Because of this I made a suggestion to throw it on another thread, but now realize that my words and the eager developers behind them might have not fully thought this through.

下面的例子示出了在左侧的电流。在右边的是什么企图

The below example shows on the left the current flow. On the right what is being attempted

切实什么我要找的就是有一个Web服务产生一个长期运行的(10-20秒)线程甚至会执行之后,Web服务已经完成。

Effectively what I'm looking for is to have a web service spawn a long running (10-20 second) thread that will execute even after the web service is completed.

这是什么,有效,是怎么回事:

This is what, effectively, is going on:

        Thread linkThread= new Thread(delegate()
        {
            Linkmembers(GetContext(), ID1, ID2, SomeOtherThing, XMLOrSomething);
        });
        linkThread.Start();



使用这个我们减少时间从19秒至2.1秒对我们的开发盒,这是相当可观。

Using this we've reduced the time from 19 seconds to 2.1 seconds on our dev boxes, which is quite substantial.

我担心的交通量,我们得到的,如果一个供应商/外线决定扼杀我们,IIS可能会决定回收/杀死那些线程之前,他们就完成了处理。我同意我们的解决方案未必是最好的,然而我们没有建立在排队机系统或其他Windows服务来处理这个时间。

I am worried that with the amount of traffic we get, and if a vendor/outside party decides to throttle us, IIS might decide to recycle/kill those threads before they're done processing. I agree our solution might not be the "best" however we don't have the time to build in a Queue system or another Windows Service to handle this.

有更好的方式来做到这一点?应该考虑的?

Is there a better way to do this? Any caveats that should be considered?

感谢。

推荐答案

除了什么注意事项从你描述的问题,我想不出任何。话虽这么说,有办法解决不涉及从头开始构建自己的解决方案的问题。

Apart from the issues you've described, I cannot think of any. That being said, there are ways to fix the problem that do not involve building your own solution from scratch.

使用的 MSMQ使用WCF :创建一个带有MSMQ端点是的 IIS托管(不需要只要WAS启用了使用Windows服务)从您的ASMX服务中,并拨打电话到服务。您获得可靠排队的所有优点,而无需建立自己的。

Use MSMQ with WCF: Create a WCF service with an MSMQ endpoint that is IIS hosted (no need to use a windows service as long as WAS is enabled) and make calls to the service from within your ASMX service. You reap all the benefits of reliable queueing without having to build your own.

另外,如果您的MSMQ服务失败或抛出一个异常,它会自动重新处理。如果使用DTC,并创下了数据库,你甚至可以有MSMQ交易流程到数据库。

Plus, if your MSMQ service fails or throws an exception, it will reprocess automatically. If you use DTC and are hitting a database, you can even have the MSMQ transaction flow to the DB.

这篇关于在Web服务独立的线程它完成后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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