You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by kpalania <kp...@yahoo.com> on 2008/09/16 23:22:03 UTC

Asynchronous Web Services using AsyncHandler

Hi,
I am trying to understand how asynchronous web services work and have been
playing with CXF (and its samples). However, it is still not clear to me. I
expect to use RESTful services but for purposes of understanding, I am
playing with the SOAP examples. Basically, this is what I want to understand
-

* Say, I have a client that calls a web service (running on a difference
geographical location) passing some XML payload as input.
* The web service parses the XML message and does some additional processing
(involves DB roundtrips etc).
* At some point, when it is done, it has to call the AsyncHandler
(handleResponse() API).

Given that the client library is ofcourse not available on the server side,
how does the server make the callback? It doesn't appear that the callback
is a webservice call (meaning, the server is not calling another web service
on the client side). How does this work? Could someone clarify please!
-- 
View this message in context: http://www.nabble.com/Asynchronous-Web-Services-using-AsyncHandler-tp19520451p19520451.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Asynchronous Web Services using AsyncHandler

Posted by kpalania <kp...@yahoo.com>.

Andrew Clegg wrote:
> 
> 
> Well, 'simpler' is pretty subjective. I personally wouldn't design any
> of my web services so that only another server could access them --
> which is what your solution implies. But then I'm building services
> for public consumption, and the client might be a few lines of Perl or
> Python, or a desktop workflow management app like Taverna, for
> example. If they can only get the results out of my service by running
> another service themselves, well that's most of my users gone.
> 
> But if your usage scenario means that you know exactly who the client
> is, and you're using web services primarily for peer-to-peer
> communication between server machines anyway, then maybe it is no less
> hassle to have a web service on each end.
> 
> Andrew.
> 

I agree. My web services are not for public consumption. They would be
called by clients that register themselves with the messaging gateway. The
registration is dynamic though. Hence, there wouldn't a static list of
clients. Everytime a new client comes into existence, it would register
itself and start calling the web services. The callback would be
communicated to the server as part of the registration process and it is a
one time thing. From then on, the client side web services would be called
everytime a message of interest appears in a JMS destination on the server
side. 
-- 
View this message in context: http://www.nabble.com/Asynchronous-Web-Services-using-AsyncHandler-tp19520451p19538149.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Asynchronous Web Services using AsyncHandler

Posted by Andrew Clegg <an...@gmail.com>.
2008/9/17 kpalania <kp...@yahoo.com>:

> What would be clean and distributed in my mind is if the callback actually
> happens to be another web service call. That way, the client registers a web
> service call as the callback and when the response is ready, the server side
> implementation simply calls the callback web service and passes the
> response. Ofcourse, this would mean that the client has a web service
> implementation as well but that seems simpler and well-detached compared to
> this AsyncHandler approach. Right?

Well, 'simpler' is pretty subjective. I personally wouldn't design any
of my web services so that only another server could access them --
which is what your solution implies. But then I'm building services
for public consumption, and the client might be a few lines of Perl or
Python, or a desktop workflow management app like Taverna, for
example. If they can only get the results out of my service by running
another service themselves, well that's most of my users gone.

But if your usage scenario means that you know exactly who the client
is, and you're using web services primarily for peer-to-peer
communication between server machines anyway, then maybe it is no less
hassle to have a web service on each end.

Andrew.

Re: Asynchronous Web Services using AsyncHandler

Posted by kpalania <kp...@yahoo.com>.
Thanks Andrew. That is very much like the approach I have in mind with some
minor differences. I don't have the need to persist the IDs in a database as
my web services dequeue messages off of a dynamic queue and they just do it
when the call is made by a client. Essentially, the client submits JMS
messages by calling a web service and retrieves JMS messages (response
messages) by calling a different web service. The client basically has a
thread that wakes up every so often and makes the second web service call
for the retrieval. However, the one downside here is that the second request
is initiated by the client as well.

What would be clean and distributed in my mind is if the callback actually
happens to be another web service call. That way, the client registers a web
service call as the callback and when the response is ready, the server side
implementation simply calls the callback web service and passes the
response. Ofcourse, this would mean that the client has a web service
implementation as well but that seems simpler and well-detached compared to
this AsyncHandler approach. Right?
-- 
View this message in context: http://www.nabble.com/Asynchronous-Web-Services-using-AsyncHandler-tp19520451p19535165.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Asynchronous Web Services using AsyncHandler

Posted by Andrew Clegg <an...@gmail.com>.
2008/9/16 kpalania <kp...@yahoo.com>:

> Wouldn't it be better if the client had a web service available and the
> callback was simply to that web service? Seems cleaner than this "sort of
> fake" asynchronous approach..

This is probably more robust -- less prone to timeouts etc. -- but the
downside obviously is that is puts a whole bunch more responsibility
(and dependencies) on the client. This is fine if you know if advance
who all the consumers of your service will be, and are in a position
to dictate requirements to them, but this often isn't the case. And it
won't work if the client is behind a firewall or a NAT router --
they'll be able to make http requests to your service, but not vice
versa.

The alternative is the submit/monitor/retrieve job model, one
implementation here (discovered via the other thread someone posted):

http://www.jroller.com/gmazza/entry/creating_service_side_asynchronous_web

This has the robustness of not needing to maintain 'fake' asyncrony
via a long background http request, but also loads very little extra
responsibility, and no extra code or architectural dependencies, onto
the client.

Andrew.

Re: Asynchronous Web Services using AsyncHandler

Posted by kpalania <kp...@yahoo.com>.
Thanks Nathan. Yeah, that is the key, I agree. Coincidentally, I had run into
that post as well. However, I am still a bit unclear as to how this would
work in a REST world, without WSDLs, etc. Any thoughts?

Wouldn't it be better if the client had a web service available and the
callback was simply to that web service? Seems cleaner than this "sort of
fake" asynchronous approach..


ndeckard wrote:
> 
> Hi, 
> 
> I found this post 
> http://www.nabble.com/Best-practice-for-paused-operations-td18437412.html#a18437412
> this post  useful.
> 
> The key idea is "Although this looks asynchronous from the point of view
> of the client
> code, all this actually does is make a normal synchronous call in a
> background thread."
> 
> - Nathan
> 
> 
> kpalania wrote:
>> 
>> Hi,
>> I am trying to understand how asynchronous web services work and have
>> been playing with CXF (and its samples). However, it is still not clear
>> to me. I expect to use RESTful services but for purposes of
>> understanding, I am playing with the SOAP examples. Basically, this is
>> what I want to understand -
>> 
>> * Say, I have a client that calls a web service (running on a difference
>> geographical location) passing some XML payload as input.
>> * The web service parses the XML message and does some additional
>> processing (involves DB roundtrips etc).
>> * At some point, when it is done, it has to call the AsyncHandler
>> (handleResponse() API).
>> 
>> Given that the client library is ofcourse not available on the server
>> side, how does the server make the callback? It doesn't appear that the
>> callback is a webservice call (meaning, the server is not calling another
>> web service on the client side). How does this work? Could someone
>> clarify please!
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Asynchronous-Web-Services-using-AsyncHandler-tp19520451p19520465.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Asynchronous Web Services using AsyncHandler

Posted by ndeckard <nd...@gmail.com>.
Hi, 

I found this post 
http://www.nabble.com/Best-practice-for-paused-operations-td18437412.html#a18437412
this post  useful.

The key idea is "Although this looks asynchronous from the point of view of
the client
code, all this actually does is make a normal synchronous call in a
background thread."

- Nathan


kpalania wrote:
> 
> Hi,
> I am trying to understand how asynchronous web services work and have been
> playing with CXF (and its samples). However, it is still not clear to me.
> I expect to use RESTful services but for purposes of understanding, I am
> playing with the SOAP examples. Basically, this is what I want to
> understand -
> 
> * Say, I have a client that calls a web service (running on a difference
> geographical location) passing some XML payload as input.
> * The web service parses the XML message and does some additional
> processing (involves DB roundtrips etc).
> * At some point, when it is done, it has to call the AsyncHandler
> (handleResponse() API).
> 
> Given that the client library is ofcourse not available on the server
> side, how does the server make the callback? It doesn't appear that the
> callback is a webservice call (meaning, the server is not calling another
> web service on the client side). How does this work? Could someone clarify
> please!
> 

-- 
View this message in context: http://www.nabble.com/Asynchronous-Web-Services-using-AsyncHandler-tp19520451p19520459.html
Sent from the cxf-user mailing list archive at Nabble.com.