1

我需要实现一个启用 WCF WS 寻址的 Web 服务,该服务基于方法的参数执行长时间运行的过程。

客户端不需要等待结果,因为它会直接传递到数据库表中。但是,Web 方法确实需要返回一个“跟踪 ID”号(实际上是一个 GUID),以便客户端可以使用它来从数据库中检索结果。

  1. Web 方法只接受接收到的参数,创建一个新的 GUID 并将所有这些信息存储在数据库表(或 MSMQ 队列)或类似的东西中。然后它将跟踪 GUID 返回给客户端。外部服务(可能是 Windows 服务)会不断轮询“收件箱”,为每个请求执行长时间运行的过程,并生成结果并响应回调服务

提前致谢

塞卡

4

1 回答 1

2

What is your question? But from your description the webservice itself is not async. In a java webapp, i would implement a simple webapp like this:

  • a webservice storing the data, starting a thread and returning the guid
  • the thread does the long term task and stores the result for its guid
  • a webservice returning the result for an guid or a fould if not finished yet.

Best practice would be to use an own deamon thread group for the long term tasks, each thread named with the guid. Override the uncaughtException() method of the group to store the exception as result for the guid on any error.

于 2008-11-12T08:58:38.463 回答