【问题标题】:Suggestion on long running process关于长时间运行过程的建议
【发布时间】:2014-03-05 13:43:05
【问题描述】:

我的要求是创建一个网站,任何数量的用户都可以在其中登录并单击按钮。单击该按钮内的任务将是一个长时间运行的过程(可能需要数小时或数天才能完成任务)。用户可以退出网站,偶尔登录也可以查看任务状态。用this文章中的想法好不好。请对此提出一些建议。

谢谢。

【问题讨论】:

  • 使用网页将作业发布到队列,然后使用服务检查队列并根据需要启动长时间运行的任务。
  • @Brian Rasmussen:你是说 Windows 服务?

标签: c# asp.net


【解决方案1】:

MSMQ 或 SQL Service Broker 用于与 Windows 服务通信。

asp.net page sends start request
                       ------------MSMQ------------>
                                              Windows service picks up message
                                              and starts the long running job.
                                              As progress is made, it can be
                                              recorded in a "Jobs" table
client checks status from the Jobs table
IIS app pool recycles
.... days pass
                                              Service completes work, and records
                                              the job as Completed

                                              Service might send email notification
                                              with a link to the webpage
client can later retrieve the rendered job

如果您真的必须留在 IIS 中,我仍然会使用 MSMQ 或 SQL Server,但您只需将服务代码放入 Application_Start

【讨论】:

  • :感谢您的建议。使用 Windows 服务是个好主意。在我的情况下将有数百个用户..我可以使用不同的线程来处理不同用户的不同工作..
  • 是的,MSMQ 可以轻松扩展到多个线程,如果需要,还允许您将服务后端扩展到多个服务器。 MSMQ 可以在装备精良的硬件上轻松处理每秒数万条消息,因此限制因素将是您的处理需求。
猜你喜欢
  • 2018-09-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-05
  • 2022-06-15
  • 1970-01-01
  • 2016-03-30
  • 1970-01-01
相关资源
最近更新 更多