[jboss-user] [JBoss Web Services Development] New message: "Re: Parallel invocations of JaxWS services and getPort"

Andrew Dinn do-not-reply at jboss.com
Mon Feb 15 05:52:53 EST 2010


User development,

A new message was posted in the thread "Parallel invocations of JaxWS services and getPort":

http://community.jboss.org/message/526305#526305

Author  : Andrew Dinn
Profile : http://community.jboss.org/people/adinn

Message:
--------------------------------------------------------------
> mailto:richard.opalka at jboss.com wrote:
>  
> Q: It is not clear to me what the JaxWS spec requires but I have assumed that each service invocation is executed using a newly created instance. Is this correct?
> A: No. Service is reused.
 
Hmm, okay, so that explains what is going on here. My service method is obtaining the message context from the WebServiceContext. If two messages come in, the first in thread A and the second in thread B then the WebServiceContext can get overwritten as follows
 
> Thread A                   Thread B
> enter myMethod
> inject WebServiceContext
>                            enter myMethod
>                            inject WebServiceContext
> read WebServiceContext
>                          read WebServiceContext
> 
> uses data for 2nd call
> 
 
This seems to me to be a tad incoherent. Even if the service method makes no reference to the state of the service implementation instance the injected data is not able to be used safely without introducing some sort of synchronization.
 
If injection happens inside the service method (e.g. using an AOP transform which does the injection inside a synchronization) then it could be made thread safe by making myMethod synchronized.
> Thread A                   Thread B
> enter myMethod
> inject WebServiceContext
> read WebServiceContext
> uses data fro 1st call
> . . .
> exits
>                            enter myMethod
>                            inject WebServiceContext
>                            read WebServiceContext
> 
 
If the injection happens before calling myMethod (e.g. using an AOP  transform which does the injection then calls the synchronized method) then  the service implementation cannot do anything about this:
 
> Thread A                   Thread B
> inject WebServiceContext
>                            inject WebServiceContext
> 
> enter myMethod
> read WebServiceContext
> uses data for 2nd call
> 
>                            enter myMethod
>                          read WebServiceContext
> 
> 
 
So, which way round does it work?

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/526305#526305




More information about the jboss-user mailing list