Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multi-threading from web service

 
Hari Jarinwallah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at this: 1.2.2 Asynchronous Web Services

http://java.sun.com/blueprints/webservices/using/webservbp3.html
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic