简体   繁体   English

C#WCF-自定义服务器端监视实现

[英]C# WCF - Custom Server-Side Monitoring Implementation

Scenario 情境

  • I've written a distributed application in C# using WCF. 我已经使用WCF用C#编写了一个分布式应用程序。
  • It uses Client/Server architecture, implementing the Publisher/Subscriber design pattern for "pushing" new data to the client. 它使用客户端/服务器体系结构,实现了发布者/订阅者设计模式,以将新数据“推送”到客户端。
  • The server-side is hosted in a windows service, the client is a windows forms app. 服务器端托管在Windows服务中,客户端是Windows窗体应用程序。
  • The server-side continually loops through a series of processes and sends the results to the client. 服务器端不断循环执行一系列过程,并将结果发送给客户端。
  • I want to add a whole area to the application for monitoring everything that is going on server-side. 我想向应用程序添加整个区域,以监视服务器端发生的一切。

Problem 问题

  • Here is where I am a bit stuck - I can't decide how I should monitor this stuff. 这是我有点卡住的地方-我无法决定如何监控这些东西。

Thoughts 思想

  • Do I create an object for storing lots of different information - logs of where the process is up to in the loop on the server-side, exceptions if any, errors etc?? 我是否创建一个用于存储大量不同信息的对象-服务器端循环中进程的运行日志,异常(如果有),错误等?
  • I guess the real question is, how can I successfully maintain a monitoring aspect of the application that gives me relevant information? 我想真正的问题是,如何才能成功维护应用程序的监视方面,从而为我提供相关信息?
  • Perhaps a central cache on the server-side that gets "snapped" at a point in time every so often and updates the client with the info? 也许服务器端的中央缓存经常在某个时间点被“快照”并用信息更新客户端?

Do you want to know what's currently going on in the server or do you also want to keep a history of what has happened? 您是否想知道服务器中当前正在发生的事情,还是想保留发生的事情的历史记录?

If you only want to know what is going on at this moment, my solution would be to maintain the current server state in-memory (this shouldn't be too hard) and have the monitoring client call the server when it wants to know what is happening. 如果您仅想知道此时发生了什么,我的解决方案是将当前服务器状态保持在内存中(这应该不太困难),并让监视客户端在服务器想知道什么时调用服务器正在发生。

If you want to keep a history of what has happened, you need some data store where the server can write events to. 如果要保留已发生事件的历史记录,则需要服务器可以向其中写入事件的数据存储。 The monitoring client can then read this data store to show what is happening now and what has happened in the past. 然后,监视客户端可以读取此数据存储,以显示现在正在发生的事情以及过去发生的事情。 Even better would be if the client did not have direct access to this data store but instead contacts the server to obtain the relevant information. 如果客户端没有直接访问此数据存储的权限,而是与服务器联系以获得相关信息,那就更好了。 This way you hide the implementation details of your monitoring history from the client. 这样,您可以从客户端隐藏监视历史记录的实现详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM