You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Evan Klinger <ek...@gmail.com> on 2010/05/11 21:21:21 UTC

Multi-threaded Services

Hello,
When developing a REST service in Axis2/C, how does Apache handle the
integration with the Axis2 module? When a request comes in that is
passed to the Axis2 module, does each request create a new instance of
the service or is it a new thread? Basically, in the service we may
need to open a file for writing but also for reading, depending upon
the request. However, we don't want to read while the file is being
written to so it seems like we need a rw lock/mutex, but that will
only work if the service is called by multiple threads. If they are
called from separate processes then I don't think this approach will
work. Any information on how to handle this would be greatly
appreciated.

Thank you
Evan

---------------------------------------------------------------------
To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
For additional commands, e-mail: c-user-help@axis.apache.org


Re: Multi-threaded Services

Posted by Damitha Kumarage <da...@wso2.com>.
Abdul Sami wrote:
> Will each Apache process simultaneously handle multiple requests by 
> using threads? or it will process requests one by one?
Apache process simultaneously handle multiple requests by using threads.

Damitha

>
> On 5/12/2010 9:54 AM, Damitha Kumarage wrote:
>> Evan Klinger wrote:
>>> Hello,
>>> When developing a REST service in Axis2/C, how does Apache handle the
>>> integration with the Axis2 module? When a request comes in that is
>>> passed to the Axis2 module, does each request create a new instance of
>>> the service or is it a new thread?
>> It is a new thread
>>>  Basically, in the service we may
>>> need to open a file for writing but also for reading, depending upon
>>> the request. However, we don't want to read while the file is being
>>> written to so it seems like we need a rw lock/mutex, but that will
>>> only work if the service is called by multiple threads. If they are
>>> called from separate processes then I don't think this approach will
>>> work. Any information on how to handle this would be greatly
>>> appreciated.
>> For each Apache process there will be a separate Axis2/C 
>> engine/service. Within that process
>> a single service would handle all requests coming for that service. 
>> So you need to handle mt.
>> Thanks,
>> Damitha
>>> Thank you
>>> Evan
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
>>> For additional commands, e-mail: c-user-help@axis.apache.org
>>>
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: c-user-help@axis.apache.org
>
>


-- 
__________________________________________________________________

Damitha Kumarage
Technical Lead; WSO2 Inc.
"Oxygenating the Web Service Platform; " http://www.wso2.com/

blog: " http://damithakumarage.wordpress.com/
__________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
For additional commands, e-mail: c-user-help@axis.apache.org


Re: Multi-threaded Services

Posted by Abdul Sami <as...@folio3.com>.
Will each Apache process simultaneously handle multiple requests by 
using threads? or it will process requests one by one?

On 5/12/2010 9:54 AM, Damitha Kumarage wrote:
> Evan Klinger wrote:
>> Hello,
>> When developing a REST service in Axis2/C, how does Apache handle the
>> integration with the Axis2 module? When a request comes in that is
>> passed to the Axis2 module, does each request create a new instance of
>> the service or is it a new thread?
> It is a new thread
>>  Basically, in the service we may
>> need to open a file for writing but also for reading, depending upon
>> the request. However, we don't want to read while the file is being
>> written to so it seems like we need a rw lock/mutex, but that will
>> only work if the service is called by multiple threads. If they are
>> called from separate processes then I don't think this approach will
>> work. Any information on how to handle this would be greatly
>> appreciated.
> For each Apache process there will be a separate Axis2/C 
> engine/service. Within that process
> a single service would handle all requests coming for that service. So 
> you need to handle mt.
> Thanks,
> Damitha
>> Thank you
>> Evan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
>> For additional commands, e-mail: c-user-help@axis.apache.org
>>
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
For additional commands, e-mail: c-user-help@axis.apache.org


Re: Multi-threaded Services

Posted by Damitha Kumarage <da...@wso2.com>.
Evan Klinger wrote:
> Damintha,
> Thank you for your reply. Does this mean I need to use the set of
> apr_* mutex functions or will the standard pthread functions be
> sufficient? Do you know of any examples that make use of mutexes?
>   
Axis2/C has implemented a wrapper layer for handling platform specific 
thread impls. In linux this wraps pthreads. You just create Axis2/C 
thread mutex and use it's functions. For example see how it is used in 
util/src/log.c

Thanks,
Damitha
> Thanks
> Evan
>
> On Tue, May 11, 2010 at 9:54 PM, Damitha Kumarage <da...@wso2.com> wrote:
>   
>> Evan Klinger wrote:
>>     
>>> Hello,
>>> When developing a REST service in Axis2/C, how does Apache handle the
>>> integration with the Axis2 module? When a request comes in that is
>>> passed to the Axis2 module, does each request create a new instance of
>>> the service or is it a new thread?
>>>       
>> It is a new thread
>>     
>>>  Basically, in the service we may
>>> need to open a file for writing but also for reading, depending upon
>>> the request. However, we don't want to read while the file is being
>>> written to so it seems like we need a rw lock/mutex, but that will
>>> only work if the service is called by multiple threads. If they are
>>> called from separate processes then I don't think this approach will
>>> work. Any information on how to handle this would be greatly
>>> appreciated.
>>>
>>>       
>> For each Apache process there will be a separate Axis2/C engine/service.
>> Within that process
>> a single service would handle all requests coming for that service. So you
>> need to handle mt.
>> Thanks,
>> Damitha
>>     
>>> Thank you
>>> Evan
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
>>> For additional commands, e-mail: c-user-help@axis.apache.org
>>>
>>>
>>>
>>>       
>> --
>> __________________________________________________________________
>>
>> Damitha Kumarage
>> Technical Lead; WSO2 Inc.
>> "Oxygenating the Web Service Platform; " http://www.wso2.com/
>>
>> blog: " http://damithakumarage.wordpress.com/
>> __________________________________________________________________
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
>> For additional commands, e-mail: c-user-help@axis.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: c-user-help@axis.apache.org
>
>
>   


-- 
__________________________________________________________________

Damitha Kumarage
Technical Lead; WSO2 Inc.
"Oxygenating the Web Service Platform; " http://www.wso2.com/

blog: " http://damithakumarage.wordpress.com/
__________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
For additional commands, e-mail: c-user-help@axis.apache.org


Re: Multi-threaded Services

Posted by Evan Klinger <ek...@gmail.com>.
Damintha,
Thank you for your reply. Does this mean I need to use the set of
apr_* mutex functions or will the standard pthread functions be
sufficient? Do you know of any examples that make use of mutexes?

Thanks
Evan

On Tue, May 11, 2010 at 9:54 PM, Damitha Kumarage <da...@wso2.com> wrote:
> Evan Klinger wrote:
>>
>> Hello,
>> When developing a REST service in Axis2/C, how does Apache handle the
>> integration with the Axis2 module? When a request comes in that is
>> passed to the Axis2 module, does each request create a new instance of
>> the service or is it a new thread?
>
> It is a new thread
>>
>>  Basically, in the service we may
>> need to open a file for writing but also for reading, depending upon
>> the request. However, we don't want to read while the file is being
>> written to so it seems like we need a rw lock/mutex, but that will
>> only work if the service is called by multiple threads. If they are
>> called from separate processes then I don't think this approach will
>> work. Any information on how to handle this would be greatly
>> appreciated.
>>
>
> For each Apache process there will be a separate Axis2/C engine/service.
> Within that process
> a single service would handle all requests coming for that service. So you
> need to handle mt.
> Thanks,
> Damitha
>>
>> Thank you
>> Evan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
>> For additional commands, e-mail: c-user-help@axis.apache.org
>>
>>
>>
>
>
> --
> __________________________________________________________________
>
> Damitha Kumarage
> Technical Lead; WSO2 Inc.
> "Oxygenating the Web Service Platform; " http://www.wso2.com/
>
> blog: " http://damithakumarage.wordpress.com/
> __________________________________________________________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: c-user-help@axis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
For additional commands, e-mail: c-user-help@axis.apache.org


Re: Multi-threaded Services

Posted by Damitha Kumarage <da...@wso2.com>.
Evan Klinger wrote:
> Hello,
> When developing a REST service in Axis2/C, how does Apache handle the
> integration with the Axis2 module? When a request comes in that is
> passed to the Axis2 module, does each request create a new instance of
> the service or is it a new thread?
It is a new thread
>  Basically, in the service we may
> need to open a file for writing but also for reading, depending upon
> the request. However, we don't want to read while the file is being
> written to so it seems like we need a rw lock/mutex, but that will
> only work if the service is called by multiple threads. If they are
> called from separate processes then I don't think this approach will
> work. Any information on how to handle this would be greatly
> appreciated.
>   
For each Apache process there will be a separate Axis2/C engine/service. 
Within that process
a single service would handle all requests coming for that service. So 
you need to handle mt.
Thanks,
Damitha
> Thank you
> Evan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: c-user-help@axis.apache.org
>
>
>   


-- 
__________________________________________________________________

Damitha Kumarage
Technical Lead; WSO2 Inc.
"Oxygenating the Web Service Platform; " http://www.wso2.com/

blog: " http://damithakumarage.wordpress.com/
__________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
For additional commands, e-mail: c-user-help@axis.apache.org