Jesse
Jesse

Reputation: 3827

How do JAXWS async calls work with polling

I need to invoke a long running task via a SOAP web service, using JAXWS on both ends, specifically, Apache CXF 2.6 on both ends.

I see that I can enable async methods in the CXF code generator, which creates two async methods per operation. Because of NAT issues, I cannot use WS-Addressing and callbacks. So I may want to use the other polling method.

I need to be sure that there will be no socket read timeouts using this mechanism, so I want to understand how it works.

Is it the case that a SOAP request is made to the server in a background thread which keeps the same, single, HTTP connection open, and the Future#isDone() checks to see if that thread has received a response?

If so, is there not a risk that a proxy server in between may define its own timeout, and cause an error if the server takes to long to respond?

What do other people do for invoking long running tasks via SOAP?

Upvotes: 4

Views: 1225

Answers (1)

Daniel Kulp
Daniel Kulp

Reputation: 14607

Yes, it would just keep checking the connection until a response is received. If something occurs between the client and server and the connection is lost, the response would not be retrievable.

For really long running things, the better approach would be to split the long running into two methods. One that would take the input and launch the work on a background thread and just return some sort of unique identifier. A second method would take that identifier and return the result. The client could call that method to kind of poll the server. That could be long running, and block or use the async methods or similar. If THAT requests times out, it could just call it again.

Upvotes: 4

Related Questions