私は私のWCFサービスServiceClient
のインスタンスをバック返すために、以下のコードを持っている:最近、私はタイムアウトを持ついくつかの問題を持っていたので、私はスロットリング動作を追加することを決定し、そのようようWCF:ServiceThrottlingBehaviorをWCFサービスに追加するにはどうすればよいですか?
var readerQuotas = new XmlDictionaryReaderQuotas()
{
MaxDepth = 6000000,
MaxStringContentLength = 6000000,
MaxArrayLength = 6000000,
MaxBytesPerRead = 6000000,
MaxNameTableCharCount = 6000000
};
var throttlingBehaviour = new ServiceThrottlingBehavior(){MaxConcurrentCalls=500,MaxConcurrentInstances=500,MaxConcurrentSessions = 500};
binding = new WSHttpBinding(SecurityMode.None) {MaxReceivedMessageSize = 6000000, ReaderQuotas = readerQuotas};
dualBinding = new WSDualHttpBinding(WSDualHttpSecurityMode.None)
{MaxReceivedMessageSize = 6000000, ReaderQuotas = readerQuotas};
endpointAddress = new EndpointAddress("http://localhost:28666/DBInteractionGateway.svc");
return new MusicRepo_DBAccess_ServiceClient(new InstanceContext(instanceContext), dualBinding, endpointAddress);
を:
var throttlingBehaviour = new ServiceThrottlingBehavior() {
MaxConcurrentCalls=500,
MaxConcurrentInstances=500,
MaxConcurrentSessions = 500
};
私の質問は、上記のコードで私はこのthrottlingBehaviour
を私のMusicRepo_DBAccess_ServiceClient
インスタンスに追加すべきですか?私はないです一方、上記のコードでは、彼らはServiceHost
を使用していることを
ServiceHost host = new ServiceHost(typeof(MyService));
ServiceThrottlingBehavior throttleBehavior = new ServiceThrottlingBehavior
{
MaxConcurrentCalls = 40,
MaxConcurrentInstances = 20,
MaxConcurrentSessions = 20,
};
host.Description.Behaviors.Add(throttleBehavior);
host.Open();
お知らせ、そして:私はウェブ上で発見例の一部から
は、彼らがこのような何かをやっています彼らはMusicRepo_DBAccess_ServiceClient
インスタンスを開いている間に(Open()
と)それを開いています...そして、これが私を混乱させました。
は、設定ファイルでこれを持っていないことはできますか? – rguerreiro
私はこのwcfサービスをapp.configファイルを持たない複数のプロジェクトと共有する必要があります。そのため、私は設定をプログラムで構築しています。 –
サービスのホスティングはどこですか? – rguerreiro