使用 WS 寻址的异步 Web 服务

发布于 2024-07-09 17:17:16 字数 350 浏览 4 评论 0原文

我需要实现一个支持 WCF WS 寻址的 Web 服务,该服务根据方法的参数执行长时间运行的进程。

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

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

提前感谢

Sekar

I need to implement an WCF WS Addressing enabled web service that performs a long running process based on the method's arguments.

The client does not need to wait for the result, because it will be delivered directly to a database table. However, the web method does need to return a 'tracking id' number (a GUID actually) so the client can use that in order to retrieve the results from the database.

  1. The web method just takes the received arguments, creates a new GUID and stores all this info in a database table (or a MSMQ queue for that matter) or something like that. Then it returns the tracking GUID to the client. An external service (Windows Service probably) would be constantly polling the 'inbox', performing the long running process for each request, and generating the results and response to the callback service

Thanks In Advance

Sekar

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天 2024-07-16 17:17:16

你的问题是什么? 但从你的描述来看,网络服务本身不是异步的。 在java web应用程序中,我会实现一个简单的web应用程序,如下所示:

  • 一个存储数据、启动线程并返回guid的web服务,
  • 该线程执行长期任务并存储其guid的结果一个
  • 返回guid结果的web服务或如果还没有完成,则犯规。

最佳实践是使用自己的守护线程组来执行长期任务,每个线程都以 guid 命名。 重写组的 uncaughtException() 方法,将异常存储为任何错误的 guid 的结果。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文