在WCF中管理状态的最可扩展的方式是什么?WCF管理会话状态信息
我只需要一个变量来表示一个会话,我将管理MSSQL中相对于会话的信息。我不需要知道会话何时结束。每天一次,我会清除任何旧的会话。
它出现SessionID是那个变量。
对于规模我使用每呼叫作为ctor是空的。我认为我不需要每个会话。
在我简单的EightBall测试中,我得到了表示会话的SessionID。但我只是在一个盒子上测试。
让我担心的是,我看到一些需要设置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;
}
很多很好的信息,但请在以下问题上明确。 “在以下配置中SessionID是否是会话的可靠指标?” – Paparazzi