排队服务呼叫 [英] Queueing up Service Calls

查看:149
本文介绍了排队服务呼叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实施使用WCF服务重Silverlight应用程序,我得给点现在在哪里偶尔有一些阻止运行的其他服务呼叫几个长期服务电话。

I'm implementing a Silverlight application that uses WCF services heavily, I've got to the point now where occasionally there are several long service calls that block other service calls from running.

这些服务最终调用超时。我想如果可以看到到执行服务的呼声此起彼伏,这样长时间通话将容纳其他呼叫,但不会导致他们超时。

These service calls eventually time out. I'd like to see if its possible to a queue system that executes service calls one after another, this way long calls will hold up other calls but won't cause them to timeout.

我使用代理服务包裹服务电话

I'm using service agents to wrap the service calls

public interface IExampleServiceAgent
{
    void ProcessData(int a, string b, EventHandler<ProcessDataCompletedEventArgs> callback);
}


Public ExampleServiceAgent1 : IExampleServiceAgent
{
     ExampleClient _Client = new ExampleClient();

     public void ProcessData(int anInt, string aString, EventHandler<ProcessDataCompletedEventArgs> callback)
     {
           EventHandler<ProcessDataCompletedEventArgs> wrapper = null;
           wrapper = (a,b) =>
           {
               callback(a,b);
               _Client.ProcessDataCompleted -= wrapper;
           }
           _Client.ProcessDataCompleted += wrapper;
           _Client.ProcessDataAsync(anInt,aString);
     }
}



以上服务代理随后将通过代码称为如下:

The above service agent would then be called from code as follows:

ServiceAgent.ProcessData(1,"STRING", (a,b) =>
{
    if (b.Error != null)
    {
         //Handle Error
    }
    else
    { 
         //DO something with the data
    }
}

有没有一种方法,我可以把这些服务电话成队列,由一个执行它们吗?

Is there a way I could put these service calls into a queue and execute them one by one?

我已经试过包装他们的行动并将其添加到队列中,但是这不会等待一到完成执行启动下一个他们调用正确没有数据被返回到调用视图模型的服务之前,虽然

I've tried wrapping them as Actions and adding them to a queue, but this does not wait for one to finish executing before starting the next one and although they do call the service correctly no data is returned to the calling ViewModel.

推荐答案

的WCF服务可以应对呼叫的数量庞大,但是,为了避免拒绝服务攻击,可处理被默认限制请求的数目

WCF services can cope with a huge number of calls but, to avoid denial of service attacks, the number of requests that can be processed is limited by default.

的显著Silverlight的WCF局限性服务将是

The significant limitations for Silverlight WCF services would be


  • 来自同一IP地址的2同时调用默认限制。

  • 系统约10-16个并发连接(文档在这一个变化)的限制

上的快速途径来提高ASP.NET,WCF和桌面客户端的性能和可伸缩性是有益的。

我猜你会立即击中第一个问题。在您的WCF的配置,你需要添加下面以增加单个IP的连接:

I am guessing you are immediately hitting the first issue. In your WCF config you need to add the following to increase the single IP connections:

<system.net> 
  <connectionManagement> 
    <add address="*" maxconnection="100" /> 
  </connectionManagement> 
</system.net>

您可以接着打第二个限制其解决方法是调整服务行为在网络/应用程序。.config文件

You may then hit the second limit for which the solution is tweak the service behaviors in the web/app.config files.

下面是一些比较详细的参考,我发现而整理这些问题自己:

Here are a few more references I found while sorting out these issues myself:

  • http://weblogs.asp.net/paolopia/archive/2008/03/23/wcf-configuration-default-limits-concurrency-and-scalability.aspx
  • Why does WCF limit concurrent connections to 5?
  • http://msdn.microsoft.com/en-us/magazine/cc163590.aspx#S10
  • http://blogs.msdn.com/b/stcheng/archive/2009/01/06/wcf-things-that-will-impact-concurrency-capacity-behavior-of-wcf-service-with-simoultaneous-client-requests-connections.aspx
  • http://www.codeproject.com/Articles/133738/Quick-Ways-to-Boost-Performance-and-Scalability-of
  • http://www.danrigsby.com/blog/index.php/2008/02/20/how-to-throttle-a-wcf-service-help-prevent-dos-attacks-and-maintain-wcf-scalability/
  • http://msdn.microsoft.com/en-us/library/7w2sway1%28v=vs.71%29.aspx
  • http://www.codeproject.com/Articles/89858/WCF-Concurrency-Single-Multiple-and-Reentrant-and
  • C# WCF: WCF stops responding after about 10 or so calls (throttling)

这篇关于排队服务呼叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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