在WCF中的长同步请求响应过程中维护状态 [英] Maintain state during the long synchronous requestresponse process in WCF

查看:102
本文介绍了在WCF中的长同步请求响应过程中维护状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有专家,



我对WCF有点新意。我有明确要求准备一个wcf应用程序,但需要以下内容:



1.需要准备IIS中托管的同步WCF服务

2。客户端将使用同步WCF服务。

3.请求和响应可能需要很长时间,因为其他应用程序涉及此过程。

4.需要维持状态这个漫长的请求和响应过程。

5.不应该使用任何工作流程





所以基本上,我需要在长同步请求< - >响应过程中保持状态而不会丢失/死锁。



请分享您的宝贵建议。



问候

balu

Hi All experts,

I am a bit new to WCF. I had explicit requirement to prepare a wcf application with below requiements,

1. Need to prepare synchronous WCF service hosted in IIS
2. Client will consume synchronous WCF service.
3. request & response might take long time, as other applications are involved in this process.
4. Need to maintain the state during this long request & response process.
5. Should not use any Workflows


So basically, I need to maintain state without lossing/deadlocks during the long synchronous request<->response process.

Please share your valuable suggestion.

Regards
balu

推荐答案

是的,这样的要求来自依赖于多种资源的服务。



我建议你提出以下几点,实现你可以达到你想要的结果:

1 - 在ServiceContract中使用以下SessionMode属性:

Yeah, requirements like this comes in case of Services which depend on multiple resources.

I''d suggest you the following points, implementing which you could achieve your desired result:
1-In ServiceContract use the following SessionMode attribute:
[ServiceContract(SessionMode=SessionMode.Required)]



2 - 在ServiceBehaviour中使用PerSession属性如下:


2-In ServiceBehaviour use PerSession attribute as following:

[ServiceBehaviour(InstanceContextMode=InstanceContextMode.PerSession)]



3 - 既然你说这个服务涉及多个应用程序,那么在ServiceBehaviour中使用Concurrency的Reentrant属性如下:


3-And since you are saying that multiple applications are involved in this Service, so use Reentrant property of Concurrency in ServiceBehaviour as following:

[ServiceBehaviour(ConcurrencyMode=ConcurrencyMode.Reentrant)]



这将帮助您避免任何类型的死锁。 />


我很确定如果你能有效地使用上述属性,那么你肯定会实现你想要的目标。



问候,

Gittu


This will help you to avoid any kind of DeadLock.

I''m sure if you could use the above properties efficiently then you would surely achieve your desired goal.

Regards,
Gittu


这篇关于在WCF中的长同步请求响应过程中维护状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆