Yes, I need to worry about thread safety. I am using WSRF. The same
service object may access different resource instances. Now I think I
should make the methods inside the resource class synchronized, i.e.,
synchronize at the resource level instead of the service level. This
can minimize the change in service class.

Thank you very much.


Regards,
Xinjun


On 7/27/06, Bhatra, Junaid <[EMAIL PROTECTED]> wrote:
You need to worry about thread safety only if you have race conditions
in your Web Service objects. Do you have such a case? If so, then it
might be better to use "request" scope. If you use "application" scope
and synchronize your methods for thread safety, it might be a
performance bottleneck in your application, since client requests will
tend to queue up. If you do not have race conditions, then use
"application" scope with no synchronization.

It's no different than writing a servlet. You never synchronize the
doGet() and doPost() methods, right?

 - Junaid


-----Original Message-----
From: Xinjun Chen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 26, 2006 11:28 AM
To: axis-user@ws.apache.org
Subject: Re: web services multithreading

Jeffrey,

Thank you for your explanation. I seems understand your question. But
I still have some doubts. The following query may make my question
clear.

I have built a web service and deployed into Axis. The scope is set as
"application". According to
<http://ws.apache.org/axis/java/user-guide.html#CustomDeploymentIntroduc
ingWSDD>,
all the requests will be served by a singleton shared object. Does it
imply that all the service operations must use keyword "synchronized"
to make the operations thread-safe?

But I seldom see others use "synchronized" keyword with a service
operation. Why? Does it imply that those services without
"synchronized" operations are not thread safe?

If multiple clients invoke the same operation of a service, how can I
ensure the thread-safety?



Regards,
Xinjun

On 7/25/06, Guo, Jeffrey <[EMAIL PROTECTED]> wrote:
> All incoming clients requests are handled by your underlying web
server
> with concurrent threads from a thread pool.  When you indicate
> application or request scope for your web service hosted in an axis
> server, it's axis engine's job to decide whether to instantiate a new
> service layer object to serve the request.
>
> -----Original Message-----
> From: Xinjun Chen [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 24, 2006 11:16 AM
> To: axis-user@ws.apache.org
> Subject: Re: web services multithreading
>
> Hi Christopher,
>
> Thank you very much for the detailed answers! :-)
>
> I have one more follow on question: Assume the service scope is set as
> "application", if there are multiple clients invoke the same
operation.
> How will this be done?
>
> According to the meaning of "application" scope, then no
multithreading
> is support. This really confused me.
>
> How to make web services scalable?
>
>
>
> Regards,
> Xinjun
>
> On 7/23/06, Christopher Sahnwaldt <[EMAIL PROTECTED]> wrote:
> > The answers all depend on the 'scope' that you set in your services
> > configuration. See http://ws.apache.org/axis/java/user-guide.html
> >
> >  > 1. At the runtime, if there are multiple clients invoke the
> > OperationA
> >
> > > concurrently, how it will be done internally?
> >
> > Your application server (Tomcat etc.) will use one thread for each
> request.
> > If scope is 'request', each request will be executed on a different
> > service object. If scope is 'application', all requests will be
> > executed on the same service object.
> >
> > > 2. I think there will be only one instance of ServiceA, right?
> >
> > If scope is 'request', a new object is created for each request.
> > If scope is 'application', the same object is re-used for all
> requests.
> >
> > > 3. Will there be one extra thread created when one invocation
> happens?
> >
> > The thread probably won't be created (it will come from a pool), but
> > that depends on your application server, not on Axis. The app server
> > will handle concurrent requests in concurrent threads.
> >
> > > 4. If the same client invokes the OperationA in two consecutive
> > > call, it is ensured that the first call will always be served
before
>
> > > the second call?
> >
> > Short answer: Yes. Long answer: Yes, as long as the client uses HTTP
> > (or another synchronous protocol) and does not make the calls in
> > different threads.
> >
> > > 5. Is there any difference about this multiple invocations in
Axis2?
> > I don't understand the question...
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to