WCFで状態を管理するための最もスケーラブルな方法は何ですか。
セッションを示すために必要な変数は1つだけで、MSSQLでセッションに関連する情報を管理します。セッションがいつ終了するかを知る必要はありません。1日1回、古いセッションをすべてクリアします。
SessionIDはその変数のようです。
スケールについては、コンストラクターが空であるため、PerCallを使用しています。セッションごとに必要だとは思いません。
私の単純なEightBallテストでは、セッションを表すSessionIDを取得しています。しかし、私は1つのボックスでテストしているだけです。
私が心配しているのは、ReliableSessionBindingElementをオンに設定する必要があるドキュメントがいくつか表示され、デフォルトでオフになっていることです。
SessionIDは、次の構成でセッションの信頼できるインジケーターになりますか?
<system.serviceModel>
<services>
<service name="MajicEightBallServiceLib.MagicEightBallService"
behaviorConfiguration="EightBallServiceMEXBehavior" >
<endpoint address=""
binding="wsHttpBinding"
contract="MajicEightBallServiceLib.IEightBall" />
<endpoint address="mex"
binding ="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/MagicEightBallService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="EightBallServiceMEXBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
[ServiceBehavior (InstanceContextMode=InstanceContextMode.PerCall)]
public class MagicEightBallService : IEightBall
{
public MagicEightBallService()
{
Console.WriteLine("Eightball awaits your question ...");
}
public string ObtainAnswerToQuestion(string userQuestion)
{
return "maybe " + OperationContext.Current.SessionId.ToString();
}
public sDoc GetSdoc(int sID)
{
List<sDocProp> props = new List<sDocProp>();
sDocProp prop1 = new sDocProp { ID = 1, Name = "Prop1", ArrivalStatus = ArrivalStatus.OnTime };
props.Add(prop1);
sDocPropStringSV prop2 = new sDocPropStringSV { ID = 1, Name = "Prop1", ArrivalStatus = ArrivalStatus.OnTime, Value = "StrValue1" };
props.Add(prop2);
sDoc sDoc = new sDoc { sID = sID, sParID = 1, Props = props, SessionID = OperationContext.Current.SessionId.ToString() };
return sDoc;
}