使用WCF监视和与Windows服务上的服务器端对象交互 [英] Monitoring and Interacting with server-side objects on a Windows service using WCF

查看:77
本文介绍了使用WCF监视和与Windows服务上的服务器端对象交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Windows服务,它通过在不同的提示上执行包和SQL命令来处理我们的ETL过程,例如丢弃在文件夹中的文件等。这必须在我们的数据仓库服务器上托管的Windows服务中完成,因为它需要由不同用户从不同的计算机进行监控。



我读过关于 ServiceController 但提供的功能非常少。我已经创建了一个对象库,有时并行执行,有时按顺序执行。这些对象包含在一个主对象中(如带有节点的树,其中每个节点包含更多节点,但所有节点都具有相同的根)。每个对象都有不同的状态,我必须监视这些状态,客户端应用程序的所有实例必须反映相同的更改。



我了解到我可以使用WCF在我的服务和客户端应用程序之间进行更详细的通信。我计划它的方式,客户端应用程序将以特定时间间隔轮询服务,服务将发送我可以使用的根对象(查看其状态)。



问题是我有时需要停止执行某些对象,或者只是调用其他方法而不用停止整个服务。我很快就了解到,在客户端实现服务合同的实例按值编组,因此更改它们不会反映在服务器端。我读到了 EndpointAddress10 ,但这需要为每个客户端实例提供不同的服务器对象实例。我需要的是,如果可能的话,所有客户端应用程序都在服务器端使用相同的实例。赛车没有任何问题,因为监控它的人只是轮流过夜和白天,并且在一个完美的场景中(ETL没有错误)不需要互动。这主要是为了解决问题和更改配置设置(这种情况不会经常发生)。



我正在尝试做什么?不同的用户使用相同的进程实例,接收数据和调用方法在服务器端运行,但从他们自己的工作站远程记录。做这个的最好方式是什么?我的客户端应用程序非常繁重。



更新:



我会试着更详细地解释一下。我有一个对象树,每个对象都可以执行,每个对象都有一个状态(Pending,Running,Succeded,Failed等)。 ETL过程是独一无二的。某些CSV文件到达指定的文件夹,并相应地触发包。在此之后,有一个暂存阶段,我不再加载文件,只是运行处理信息的SQL语句和包。我创建的对象负责处理每个对象的顺序(有序列和并行执行)。有时,当一个包失败时,依赖于其成功的其他包被取消。当操作员修复问题时,他应该能够重新启动它停止的过程。



现在这一切都在Windows窗体应用程序中完成。这具有在特定用户的会话中运行的缺点,因此只有所述用户可以查看进度并与其相互作用。如果其他用户想要查看他无法进行的进度,因为应用程序未在其会话中运行。这个想法是服务域帐户将用于运行Windows服务,所有用户将使用Windows窗体应用程序与服务进行通信。我需要能够重新启动执行并从客户端应用程序调用其他方法,但所有将在服务器端执行。客户端只是一个代理。

I'm building a Windows Service that takes care of our ETL process by executing packages and SQL commands on different cues, like files dropped in a folder and such. This must be done in a windows service hosted on our data warehouse server, because it needs to be monitored from different computers by different users.

I've read about the ServiceController but that provides very little functionality. I have created a library of objects that take care of execution sometimes in parallel and sometimes sequentially. These objects are contained in one main object (like a tree with nodes, where each node contains more nodes, but all have the same root). Each object has a different state and I must monitor these states and all the instances of the client application must reflect the same changes.

I learned I can have a more verbose communication between my service and the client application using WCF. The way I plan it, the client application will poll the service at a certain time interval and the service will send the root object that I can work with (view their states).

The problem is that I sometimes need to stop the execution of certain objects, or just call other methods without stopping the entire service. I quickly learned that the instances that implement the service contract at client-side are marshal by value, thus changing them won't be reflected at the server-side. I read about the EndpointAddress10 but that requires a different instance of the server object for each client instance. What I need is, if it is possible, that all client applications work with the same instance at server-side. There won't be any problems with racing, since the guys monitoring it just take turns over the night and during the day, and in a perfect scenario (no errors in the ETL) interaction won't be needed. This is mostly for trouble shooting and changing configuration settings (which won't happen often).

Is what I'm trying to do possible? Different users working with the same instance of the process, receiving data and calling methods to be run at server-side but logged remotely from their own work stations. What is the best way to do this? My client-side application is pretty heavy.

UPDATE:

I'll try to explain in more detail. I have a tree of objects that can each be executed, and each has a state (Pending, Running, Succeded, Failed, etc.). The ETL process is unique. Some CSV files arrive at a specified folder and the packages are triggered accordingly. After this, there's a staging phase where I'm not loading files anymore but just running SQL statements and packages that process the info. The objects I created take care of the order in which each should be executed (there are sequences and parallel executions). Sometimes, when one package fails the others that depend on its success are canceled. When the operator fixes the problem, he should be able to restart the process where it left off.

Right now this is all done in a windows forms app. This has the disadvantage of running in a specific user's session, thus only said user can view the progress and intereact with it. If a different user wanted to see the progress he wouldn't be able to because the application isn't running in his session. The idea is that a service domain account will be used to run the windows service and all users will use the windows forms application to communicate with the service. I need to be able to restart execution and call other methods from the client applications but everything will be executed server side. The client side is just a proxy.

推荐答案





可能。



您可以尝试: WCF服务中的交易 [ ^ ]



我认为这会解决你的目的,但我对你的情景非常感兴趣,非常有趣。



如果您在用户术前详细说明您的确切要求以及您的目标用户的详细信息,我想我们可能会找到一些更好的方法来完成您的工作。



谢谢

Suvabrata
Hi,

Its Possible.

You can try : Transactions in WCF Services[^]

I think this will solve your purpose but I am really interested about your scenario and its very interesting.

If you elaborate your exact requirement in terms of User Preoperative and details of your tergeted users I think we may found some better way to accomplish your job.

Thanks
Suvabrata


这篇关于使用WCF监视和与Windows服务上的服务器端对象交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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