Writing async service using cxf with java first approach

匿名 (未验证) 提交于 2019-12-03 08:54:24

问题:

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

回答1:

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.


回答2:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!