在会话合约中使用单向操作是否被认为是一种糟糕的设计?
我读过,如果使用 SessionMode.PerSession 实例化,则不应在会话合约中使用单向操作,但是当 < em>SessionMode 要么是每次调用,要么是每次单例。
任何想法为什么单向操作不应该与每个会话一起使用,而它们可以与每个调用和每个单例一起使用?
谢谢
I've read that one-way operations shouldn't be used in a sessionful contract if using SessionMode.PerSession instantiation, but it is not a bad design to use one-way operations with sessionful contract when SessionMode is either per-call or per-singleton.
Any ideas why one-way operations shouldn't be used with per-session, while they can be used with per-call and per-singleton?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用单向操作,您不知道它是否会导致服务异常。服务上未处理的异常总是会导致通道出现故障。如果
InstanceContextMode
设置为PerSession
,它将导致会话通道出现故障并释放服务实例。由于单向方式,客户端不会知道这一点,并且从同一客户端代理对服务的下一次调用将以异常结束(通道出现故障......)。客户端只能在代理上调用Abort
,但他不会知道这一点。 IMOSingle
启用会话的实例的行为非常相似,只是它不会释放服务实例。这不会发生在正如评论中指出的,它将在PerCall
实例中,因为每次调用实例使用通道堆栈进行单个请求处理。PerCall
实例中发生以及由于会话通道故障。If you use One-Way operation you don't know if it caused exception on the service. Unhandled exception on the service always faults the channel. If
InstanceContextMode
is set toPerSession
it faults sessionful channel and it disposes service instance. Because of the one way nature client will not know about it and next call to the service from the same client proxy will end with exception (channel is faulted ...). Client will be only able to callAbort
on the proxy but he will not know about that. IMOSingle
instancing with session enabled will behave quite similar except it will not dispose service instance.This will not happend withAs pointed in comment it will happen inPerCall
instancing because per call instancing uses channel stack for single request processing.PerCall
instancing as well because of faulted sessionful channel.