Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JAX-WS Async call  RSS feed

Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question to interpret the following statement in the below link

Using an asynchronous message exchange

By default, asynchronous client invocations do not have asynchronous behavior of the message exchange pattern on the wire. The programming model is asynchronous; however, the exchange of request or response messages with the server is not asynchronous. To use an asynchronous message exchange, the property must be set on the client request context with a boolean value of true. When this property is enabled, the messages exchanged between the client and server are different from messages exchanged synchronously. With an asynchronous exchange, the request and response messages have WS-Addressing headers added that provide additional routing information for the messages. Another major difference between asynchronous and synchronous message exchange is that the response is delivered to an asynchronous listener that then delivers that response back to the client. For asynchronous exchanges, there is no timeout that is sent to notify the client to stop listening for a response. To force the client to stop waiting for a response, issue a Response.cancel() method on the object returned from a polling invocation or a Future.cancel() method on the object returned from a callback invocation. The cancel response does not affect the server when processing a request.

My question here is only when we set the "mep" property the client then starts the local http server connection and waiting for the reponse from the server. But if we did not set this flag then either your actual client will be waiting (Polling method) or the listener might be waiting (call back method).

1) Use polling method and then call cancel() method will result in cancelling all the waiting threads on the client side to receive the reponse
2) set the mep flag but still call the cancel method will result terminating the above the new Http connection

the point i want to make sure is we use async call to "call and return" and i dont want any threads to wait on the client side expecting the results based on my requirement.

Can any of you thought about this ?

Ranch Hand
Posts: 2198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want a truly asynchronous web service with the service calling the client and the service generating some kind of result, here is what you can do:
1. Implement the service to insert the request into some kind of queue and then immediately return.
Example of queues are ApacheMQ, Java SE classes implementing the java.util.Queue interface, a JMS queue etc.
2. Implement a callback service on the client side.
The service server needs a way to tell the client that a result of the request submitted by the client is ready.
You can also use polling, in which case you do not need a callback service on the client side.
Best wishes!
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
Rocket Oven Kickstarter - from the trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!