This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes multi-threading from web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "multi-threading from web service" Watch "multi-threading from web service" New topic
Author

multi-threading from web service

Hari Jarinwallah
Greenhorn

Joined: Sep 19, 2011
Posts: 3
Hi all,

I've requirement to start some processing after receiving a request and validating the same. The return of the web service response needs to be sent immediately after kicking off the process and shouldn't wait for it to be finished.

One possible way to do this was using different threads. But, my application is deployed on weblogic and for web service, it's using axis 1.4 (old application). I've read that it's not a good idea to create our own threads when weblogic is managing the same.

I am sure that this is very regular scenario so can any one guide me about what should be the correct approach?

thanks a lot!
Hari
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Since you are using an application server, have you considered sending asynchronous messages to a message driven bean?
This way, the web service is free to return immediately and there can be multiple instances of the MDB processing requests in parallel.
If you are able to use EJB 3.1, you do not need to use an MDB, since regular session beans can also be invoked asynchronously.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 412
    
    3
Have a look at this: 1.2.2 Asynchronous Web Services

http://java.sun.com/blueprints/webservices/using/webservbp3.html
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Right, if you only need asynchronicity, then an asynchronous web service will suffice.
I was under the impression that you wanted parallel processing when I wrote my reply.
Best wishes!
Hari Jarinwallah
Greenhorn

Joined: Sep 19, 2011
Posts: 3
Thanks for the replies.

And yes, only asynchronous operation will do the trick for me. What I want is to trigger some processes and without waiting for them to complete, return the web service response to client.

I don't want to go for asynchronous web service as I want to avoid the serialization overhead. But, I wonder if we have any way of calling these web services locally. Also, Axis 1.4 - not sure if it supports asynchronous web service.
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 412
    
    3
1. If you draw a UML sequence diagram for the section/link given, you will see the complete flow proposed.

2. Roughly and simplified is

H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 412
    
    3
Picture-wise, if it help to visualize

http://java.sun.com/developer/technicalArticles/xml/jaxrpcpatterns/index6.html
See Figure 10: Asynchronous services with JAX-RPC

If you only interest Processing subsystem part.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multi-threading from web service