使用 cxf 和 java 第一种方法编写异步服务

发布于 2024-09-03 08:21:25 字数 151 浏览 2 评论 0原文

我需要使用 cxf 和 java 第一种方法创建一个异步 Web 服务。但我无法

找到任何网络资源/网站来告诉我如何做到这一点?

您能告诉我如何使用 CXF 和 java 第一种方法编写异步 Web 服务吗?

谢谢谢卡尔

I need to create a async webservice using cxf with java first approach. But i am unable to

find any web resource/ website which tells me how to do this?

Can you please tell how can I write a async webservice using CXF with java first approach?

Thanks

Shekhar

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

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

发布评论

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

评论(2

纵性 2024-09-10 08:21:25

一个可以在多种情况下使用的简单替代方案:

  1. 从客户端执行正常的 Web 服务。
  2. 在服务器上,在新线程中启动作业并返回类似“作业已启动”的状态。
  3. 当作业完成时,让服务器将结果发送回客户端。

优点:

  • 简单!
  • 您可以快速得到结果,了解该工作是否被接受。

缺点:

  • 客户端和服务器都必须侦听传入的 Web 服务。
  • 通常需要 id 处理来将结果与原始任务相匹配。

A simple alternative that can work in many situations:

  1. Execute a normal web service from the client.
  2. On the server, start the job in a new thread and return with a status like "job started"
  3. When the job is finished, let the server send the result back to the client.

Advantages:

  • It's simple!
  • You get a quick result that tells if the job is accepted.

Disadvantages:

  • Both the client and server must listen for incomming web services.
  • Often requires an id handling to match the result with the original task.
一抹微笑 2024-09-10 08:21:25

在 Web 服务后面使用 ActiveMQ 等消息传递基础设施 - 正常获取 Web 服务请求,获取请求消息并将其发布到 ActiveMQ 中的入站队列,并同步响应确认。使用一些批处理基础设施(批处理作业、队列上的侦听器等)处理入站队列,然后在处理完成后,将完成信息发布回调用者 - 使用消息传递基础设施或与数据库结合使用。

Use a messaging infrastructure like ActiveMQ behind your webservice - get the webservice request normally, take the request message and post it to an inbound queue in ActiveMQ and respond with an acknowledgement synchronously. Process the inbound queue using some batch infrastructure (batch jobs, listeners on Queue etc) and then once processing is complete, either post a completion back to the caller - either using the messaging infrastructure or in conjunction with DB.

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