You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Faraz Rasheed <fa...@yevolve.com> on 2004/04/22 06:54:13 UTC

Single threaded web service

Hi,
 
I am developing a web service using axis. The problem is that, by
default, the axis web services are multithreaded (more than one threads
are used to entertain user requests). What I want is a single threaded
web service which uses a single thread to entertain all the user
requests. Is it possible? If yes then how?
 
Regards,
Faraz Rasheed
faraz.rasheed@yevolve.com
Software Engineer
yEvolve Pvt. Ltd.
www.yevolve.com <http://www.yevolve.com/> 
 

Re: Single threaded web service

Posted by Richard Martin <rm...@essex.ac.uk>.
Hi Tom, Faraz!

You can achieve this by specifying an application scope service and 
synchronize all of its methods. Only a single instance of an application 
scoped service is created to handle all requests, and if you synchronise 
then this should reduce execution to a single threaded manner?

The alternative method of doing it if you really _really_ want only one 
thread would be to look into the documentation of your servlet 
container; Tomcat provides a maxThreads=? attribute in the HTTP 
Connector element in server.xml. You could set this to 1 to achieve the 
correct number of worker threads? Be warned however, this solution will 
cripple any other web services/web sites that may be running.

Regards,

Richard


Tomasz Pik wrote:

> Faraz Rasheed wrote:
>
>> *Hi,*
>>
>>  
>>
>> I am developing a web service using axis. The problem is that, by 
>> default, the axis web services are multithreaded (more than one 
>> threads are used to entertain user requests). What I want is a single 
>> threaded web service which uses a single thread to entertain all the 
>> user requests. Is it possible? If yes then how?
>
>
> Write your own class:
>
> import javax.servlet.SingleThreadModel;
> import org.apache.axis.transport.http.AxisServlet;
>
> public class SingleThreadedAxis extends AxisServlet
>        implements SingleThreadModel {
> }
>
> and register this class in web.xml instead of AxisServlet.
> This will delegate handling of your problem to servlet engine.
> But I'm worry, that Axis itself do some thread managmenet.
> If yes, maybe somebody having better understanding of Axis
> internals will help.
>
> HTH,
> Tomek
>
>> *Faraz Rasheed
>
>
>



Re: Single threaded web service

Posted by Tomasz Pik <pi...@ais.pl>.
Faraz Rasheed wrote:

> *Hi,*
> 
>  
> 
> I am developing a web service using axis. The problem is that, by 
> default, the axis web services are multithreaded (more than one threads 
> are used to entertain user requests). What I want is a single threaded 
> web service which uses a single thread to entertain all the user 
> requests. Is it possible? If yes then how?

Write your own class:

import javax.servlet.SingleThreadModel;
import org.apache.axis.transport.http.AxisServlet;

public class SingleThreadedAxis extends AxisServlet
        implements SingleThreadModel {
}

and register this class in web.xml instead of AxisServlet.
This will delegate handling of your problem to servlet engine.
But I'm worry, that Axis itself do some thread managmenet.
If yes, maybe somebody having better understanding of Axis
internals will help.

HTH,
Tomek

> *Faraz Rasheed