WCF配置服务器记住数据 [英] WCF Configuring server to remember data

查看:152
本文介绍了WCF配置服务器记住数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在WCF服务的地方处理由客户提出的要求。然而,缓存客户端发送它的一些数据。那么它的数据计算。

I currently have a service in WCF where it processes requests made by a client. However, it caches some data that the client sends it. It then does computations on the data.

目前的任何点的客户端应能够检索的一些数据。它是在用户的自由裁量权(点击按钮时,一个AJAX查询发送到获取的一些数据)。

At any point the client should be able to retrieve some of the data. It is at the discretion of the user (when a Button is clicked, an AJAX query is sent to get some of the data).

时遇到的问题是,当其他客户机连接,并开始发送请求,发送该原始客户机现在被扭曲的数据。

The problem I'm having is that as soon as another client connects, and starts sending requests, the data that the original client sent is now distorted.

我不知道我怎么能解决这个问题。我已经尝试使用会话,因为我一直在寻找一些方法可以让我实例化我的服务对象为要连接到它的每个客户端。仍然没有运气。

I was wondering how I can resolve this. I've attempted to use sessions, as I was looking for some way I can instantiate my "server object" for each client that wants to connect to it. Still no luck.

此问题是与此有关:
WCF关闭连接/解除资源

推荐答案

听起来也许你正在寻找一个WCF经久耐用(的链接)。耐用的服务可以保持通话状态之间的一个服务。

Sounds like maybe you're looking for a WCF Durable Service (link). Durable services can keep state between calls to a service.

第4章在Juval洛伊的编程WCF服务(链接)也有关于持久服务信息,以及因为每个会话服务,也可能有帮助。

Chapter 4 in Juval Lowy's Programming WCF Services (link) also has information about Durable Services as well as per-session services which might also help.

在一般情况下,虽然,它的好习惯让你的WCF服务的无状态 - 即不保留调用之间的任何状态。耐用的服务受到持续的数据,例如电话之间的数据库,而不是真正保持它在内存中(这可能是一件坏事,如果你有数千个并发服务的消费者)做到这一点。

In general, though, it's considered good practice to make your WCF services stateless - i.e. don't hold onto any state between calls. Durable services accomplish this by persisting data, for example to a database between calls instead of actually keeping it in memory (which could be a bad thing if you have thousands of simultaneous service consumers).

这篇关于WCF配置服务器记住数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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