.net 如何让WCF MSMQ一次获取超过10条消息?
我已经通过编程方式设置了msmq绑定和限制,但即使指定MaxConcurrentCalls、MaxConcurrentSessions和MaxConcurrentInstances的值高于10,我也无法一次处理超过10条消息 以下是创建主机的代码:.net 如何让WCF MSMQ一次获取超过10条消息?,.net,wcf,msmq,.net,Wcf,Msmq,我已经通过编程方式设置了msmq绑定和限制,但即使指定MaxConcurrentCalls、MaxConcurrentSessions和MaxConcurrentInstances的值高于10,我也无法一次处理超过10条消息 以下是创建主机的代码: var host = new ServiceHost(typeof(MqProcessRequestServer)); var binding = new NetMsmqBinding(NetMsmqSecurityM
var host = new ServiceHost(typeof(MqProcessRequestServer));
var binding = new NetMsmqBinding(NetMsmqSecurityMode.None)
{
UseSourceJournal = true,
ReceiveErrorHandling = ReceiveErrorHandling.Drop,
ReceiveRetryCount = 0,
MaxRetryCycles = 0,
RetryCycleDelay = TimeSpan.FromMinutes(1),
ExactlyOnce = true,
Durable = true,
MaxReceivedMessageSize = 4000000000,
ReceiveTimeout = TimeSpan.FromSeconds(30)
};
var queueUri = string.Format("net.msmq://localhost/private/{0}", scriptEngineVersion);
host.AddServiceEndpoint(typeof(IMqProcessRequest), binding, queueUri);
// Set throttling to ScriptEngine.Capacity in datamodel
var throttling = new ServiceThrottlingBehavior
{
MaxConcurrentCalls = capacity,
MaxConcurrentSessions = capacity,
MaxConcurrentInstances = capacity
};
host.Description.Behaviors.Add(throttling);
// Set service timeout
var behavior = host.Description.Behaviors.Find<ServiceBehaviorAttribute>();
behavior.TransactionTimeout = TimeSpan.FromSeconds(60).ToString();
我尝试了不同的容量值,小于10的都可以正常工作,因为我最多只配置了10个,但大于10的只有10个。允许的10个连接是由
ServicePointManager.DefaultConnectionLimit上的默认值造成的
在有关该设置的“注释”部分中,它说:
在服务器环境(ASP.NET)中使用时,DefaultConnectionLimit默认为更高的连接数,即10
在无服务器环境中,默认值为2
若要允许在应用程序启动时设置更多连接,请在加载appdomain时使用DefaultConnectionLimit
ServicePointManager.DefaultConnectionLimit = 100;
上述线路应允许100个连接
ServicePointManager.DefaultConnectionLimit = 100;