You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Sica, David (David)" <ds...@avaya.com> on 2008/04/07 16:58:19 UTC

Long running process and threads

I'm creating a web service that needs to do some processing that will
take too long to perform and return to the client synchronously.  I'm
considering giving the client back a transactionid immediately, storing
it in a database, then spawning a thread which will do the long running
task and update the database mapping between the transactionid and the
results which the client can query later.

My main question is if there's anything special I should consider about
spawning threads from a CXF web service in this fashion or if this is a
bad idea?

Thanks,
David


Re: Long running process and threads

Posted by Daniel Kulp <dk...@apache.org>.
On Monday 07 April 2008, Sica, David (David) wrote:
> I'm creating a web service that needs to do some processing that will
> take too long to perform and return to the client synchronously.  I'm
> considering giving the client back a transactionid immediately,
> storing it in a database, then spawning a thread which will do the
> long running task and update the database mapping between the
> transactionid and the results which the client can query later.
>
> My main question is if there's anything special I should consider
> about spawning threads from a CXF web service in this fashion or if
> this is a bad idea?
>
> Thanks,
> David

That should all work perfectly.   

Another option to consider though:  if the clients are in a position 
where they can open a port/service, you COULD have the client create a 
callback service and pass the WSA refernce to that service to the 
server.   When the server is done, it would just call back on the 
callback to say "done".  That does require the server to be able to open 
ports back to the client though.   That could be problematic with 
firewalls/routers and such.   

Couple notes:
1) We have a callback demo that show this.

2) This will be easier with 2.1 as the WSA support is built right into 
the JAX-WS API's.  No need to drop to CXF proprietary stuff.



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: Long running process and threads

Posted by Christian Vest Hansen <ka...@gmail.com>.
Should work just fine, especially if you only rely on jax-ws or
somesuch interface for communicating with the outside world. That is
to say, if you don't work directly with the CXF innards such as the
bus, the exchange and interceptors, during your concurrent execution -
not that I don't think there's a good and thread-safe way to do this,
I just caution to a little thinking toward getting it right.



On 4/7/08, Sica, David (David) <ds...@avaya.com> wrote:
> I'm creating a web service that needs to do some processing that will
>  take too long to perform and return to the client synchronously.  I'm
>  considering giving the client back a transactionid immediately, storing
>  it in a database, then spawning a thread which will do the long running
>  task and update the database mapping between the transactionid and the
>  results which the client can query later.
>
>  My main question is if there's anything special I should consider about
>  spawning threads from a CXF web service in this fashion or if this is a
>  bad idea?
>
>  Thanks,
>
> David
>
>


-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.