WWF - 初学者关于 Windows 工作流服务的简单设计决策
我想开发一个工作流服务。
我所做的如下:
- 我向服务发送图像的 url
- 将一条新记录插入到数据库中,并显示 imageABC.jpg 状态:“待处理”
- 服务会下载映像并将其保存在文件系统上
- 当服务器可以开始处理它更新的映像时, 状态为“开始处理”
- 服务对图像进行一些图像处理(时间 消耗)
- 服务完成图像处理作业并更新状态 到数据库表中的“完成”,
- 服务会发送带有图像 url 的响应问题
: 我希望计算机一次仅对一张图像进行图像处理(我使用共享托管,因此资源有限)
如何确保用户可以调用该服务,并且该服务将执行步骤 1,2,3 (因为这并不是非常耗时)但是会等到上一个图像完成处理吗?
请给我任何建议。我是新人,刚刚学习。 谢谢。
PS:我还想允许客户端通过询问数据库的状态来查看其图像的状态。我可以将其合并到工作流程服务中吗?我应该这样做还是应该将其作为一项单独的服务?
I want to develop a workflow service.
What I do is the following:
- I send the service the url to an image
- A new record is inserted into the DB saying imageABC.jpg
status:"pending" - the service downloads the image and saves it on the file system
- when the server can begin working on the image it updates the
status to "begin processing" - the service does some image processing on the image(time
consuming) - the service finishes the image processing job and updates status
to "done" in the DB table - the service sends a response with the url to the image
Question:
I want the computer to do the image processing on only one image at a time( I am using shared hosting so resources are limited)
How can I make sure that users can call the service, and the service will do steps 1,2,3 (because this is not extremly time consuming) but than will wait until the previous image has finished processing?
Please give me any advice. I am new and just learning.
Thank you.
PS: I also want to allow the client to see what is the status of it's image by interogating the DB for the status. Can I incorporate this into the workflow service? should I do this or should it be a separate service?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你要么同步做事,要么异步做事。你所描述的对我来说听起来就像是混合物。
单个方法调用可以一次完成所有操作,从而迫使客户端等待一切完成,或者您可以提供客户端可以调用的不同方法来确定状态,例如。
因此,您的客户将向您的服务提交下载。然后,该服务会将
imageUrl
保存在数据库中,状态为Pending
。计划任务(基本上是另一个应用程序)将读取所有待处理任务并开始下载,将每个下载任务标记为正在处理
。当计划任务下载并处理图像后,它会将结果保存在某个地方(很可能保存在文件中,如果您坚持的话,也可以保存在数据库中)并将状态设置为“完成”...虽然这一切正在进行时,客户端将通过调用GetStatus
方法轮询服务的当前状态。轮询间隔应调整为您的作业下载和处理图像所需的预期时间。一旦客户端从GetStatus
收到Done
状态,它就知道可以调用GetResult
并检索图像。Either you do stuff synchronously or asynchronously. What you are describing sound to me like a mixture.
A single method call can do it all at once, thus forcing the client to wait until everything is done, or you can offer different methods that the client can call to determine the status, such as.
So your client would submit a download to your service. The service will then save the
imageUrl
in the database as statusPending
. A scheduled task (another app basically) will read all pending tasks and begin downloading, marking every download task asProcessing
. When the scheduled task has downloaded and processed the image it will save the result somewhere (in a file most likely, or in the database if you insist) and set the status toDone
... While all this is going, on the client will poll the service for the current status by calling theGetStatus
method. The polling interval should be adjusted to the expected time it takes for your job to download and process the image. Once the client receives aDone
status fromGetStatus
it knows that it can callGetResult
and retrieve the image.使用消息队列实现图像处理。当文件上传到服务器然后将其保存到磁盘时,将记录插入数据库并通过将消息插入队列来对文件进行排队以进行处理。然后处理队列中的图像,一次处理一张,完成后更新数据库中的文件状态。
Implement your image processing using a message queue. When file is uploaded to the server then save it to disk, insert a record into the database and queue the file for processing by inserting a message into a queue. Then process the images from the queue, one at a time, and when finished update file status in the database.