简体   繁体   English

如何确定我的Windows服务已完成对来自远程应用程序的请求的处理?

[英]How to determine that my windows service has finished processing my request from remote application?

I have a windows service that listens to a message queue and processes request from this message queue. 我有一个Windows服务,可侦听消息队列并处理来自此消息队列的请求。 I have an initial application that places messages in the message queue. 我有一个将消息放入消息队列的初始应用程序。 The service itself actually creates some files on the fly and when these files are created I need the initial application to grab these files and essentially paint them on the screen. 该服务本身实际上是在动态创建一些文件,创建这些文件时,我需要初始应用程序来抓取这些文件并从本质上将它们绘制在屏幕上。 (the files are an html format) For the time being I have the application and the service running on my local machine so the files are just located on the c: drive of my machine. (文件是html格式)暂时,我在本地计算机上运行了应用程序和服务,因此文件仅位于计算机的c:驱动器上。

My issue is that I need some way to signal my initial application that the service has picked up and processed my msg successfully or unsuccessfully. 我的问题是,我需要某种方式来向我的初始应用程序发出信号,表明该服务成功或不成功地接收并处理了我的味精。 I have been researching how to do this and have come up empty handed. 我一直在研究如何做到这一点,空手而归。 I have also been brainstorming ideas as to what I could do to make this work. 我也一直在集思广益,想方设法完成这项工作。 One non viable solution was to insert a record into a database table when sending a msg to the queue and upon processing finished within the service update the queue record, all the while having the application query the table checking for a status of processing complete. 一种不可行的解决方案是,在将msg发送到队列时,将记录插入数据库表中,并且在服务内完成处理后,更新队列记录,同时让应用程序查询表以检查处理状态。 I don't like this idea at all as I feel like it would be too intensive, and I believe that there has to be a better way of doing this. 我根本不喜欢这个想法,因为我觉得它太过于密集了,我相信必须有更好的方法来做到这一点。 I am going to continue to research how this can be done, but I am definitely hoping someone has a better solution to this than my sql query running over and over again. 我将继续研究如何做到这一点,但我绝对希望有人能比我的SQL查询一遍又一遍有更好的解决方案。 Note in the past I have tried to query the event viewer for processes, and I know how to do this, but this will take far too long for the timing I am looking to accomplish. 请注意,过去我曾尝试向事件查看器查询进程,而且我知道如何执行此操作,但这对于我要完成的时间将花费太长时间。

I ended up going with the route of inserting record into database prior to call windows service. 我结束了在调用Windows服务之前将记录插入数据库的方法。 Then when the windows service finished with its process it updated this db record. 然后,当Windows服务完成其处理过程时,它将更新此db记录。 All the while my page is calling a webservice via javascript which checks the db to see if the flag on the record has been set to done processing. 我的页面一直在通过javascript调用Web服务,该服务检查db以查看记录上的标志是否已设置为完成处理。 This allows me to determine when the windows service has finished processing my msg from the queue. 这使我可以确定Windows服务何时从队列中完成了对味精的处理。

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

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