[JBoss Web Services Development] New message: "Re: Parallel invocations of JaxWS services and getPort"
by Andrew Dinn
JBoss development,
A new message was posted in the thread "Parallel invocations of JaxWS services and getPort":
http://community.jboss.org/message/526321#526321
Author : Andrew Dinn
Profile : http://community.jboss.org/people/adinn
Message:
--------------------------------------------------------------
Ok, I'm beginning to get the message here: the EG obviously didn't do a very thorough job up to 2.1. What boggles me is that all these issues have been thought about when it comes to EJBs. Let's hope Alessio can resolve some of these problems.
The web servcie context and its uderlying message context is the specified way of passing state between handler and service bean so it is important to make this work efficiently. It is still possible to make accesses thread safe. Make the injected context is a single static wrapper instance which contains a ThreadLocal. Aroudn each call the Web Service code can install and then remove thread-specific implementation instances of the current service context. The wrapper can indirect API calls to these per-thread instances to retrieve thread specific data.
That avoids the need to synchronize the whole web method when all that is really required is thread-safe access to the underlying message context and, from there, data cached by the handler. This will significantly benefit throughput. This is +extremely+ important because your decision to use only a single bean is a serious potential bottleneck. Even if the bean itself does not contain any shared state it cannot employ the message context without synchronizing all service methods and hence serialising all calls. Obviously the handler and thread could use their own thread local to communicate data in a thread-safe manner. However, rather than require each application to replicate a mechanism already defined in the spec it would be better to make the specified mechanism work safely.
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/526321#526321
14 years, 4 months
[JBoss Web Services Development] New message: "Re: Parallel invocations of JaxWS services and getPort"
by Richard Opalka
JBoss development,
A new message was posted in the thread "Parallel invocations of JaxWS services and getPort":
http://community.jboss.org/message/526313#526313
Author : Richard Opalka
Profile : http://community.jboss.org/people/richard.opalka@jboss.com
Message:
--------------------------------------------------------------
Andrew Dinn wrote:
*Q: So, which way round does it work?*
I'm affraid this is another question for our JAX-WS EG
We implemented https://jira.jboss.org/jira/browse/JBWS-2486
because of *performance and lifecycle issues*.
There's @PostConstruct and @PreDestroy lifecycle requirement
in JAX-WS 2.2 spec that defines these lifecycle methods.
We had users who were complaining these methods were called
so many times, how many request came in, see:
http://community.jboss.org/message/337861#3327860
However your usecase requires it to not be shared and be created instance per request.
This introduces real performance penalty that incorporates:
* bean instantiation (calling constructor) (per request)
* scanning the bean class for lifecycle annotations (@PostConstruct & @PreDestroy) (per request)
* calling the @PostConstruct before method invocation (per request)
* calling the @PreDestroy after method invocation (per request)
As you can see injecting WebServiceContext per request is really bad idea introduces in JAX-WS.
I'm really sorry I have to repeat it again, but *JAX-WS spec. is broken by design*
This question needs to be clarified in JAX-WS spec.
PS1: I bet Sun RI also contains this reused service implementation we have.
PS2: JAX-WS endpoints according to JAX-WS spec are meant not to be used in concurrency scenarios
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/526313#526313
14 years, 4 months
[JBoss Web Services Development] New message: "Re: Parallel invocations of JaxWS services and getPort"
by Andrew Dinn
JBoss 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@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
14 years, 4 months
[JBoss Web Services Development] New message: "Re: Parallel invocations of JaxWS services and getPort"
by Andrew Dinn
JBoss development,
A new message was posted in the thread "Parallel invocations of JaxWS services and getPort":
http://community.jboss.org/message/526296#526296
Author : Andrew Dinn
Profile : http://community.jboss.org/people/adinn
Message:
--------------------------------------------------------------
My test case is a little bit too complicated to just hand over. It is one of the WSTX tests which is implemented in the XTS WSTX test war which is deployed to the maven repo along with the XTS release. The broken test is one of about 30 tests implemented in the war. These tests only run as a complete test suite using a web form to drive the run and report outcomes. Also, you need to deploy the XTS sar wth the test war as the broken test relies upon communicating with 4 of the XTS services. To make it more complicated the problem does not show up reliably on every run as it is dependent upon the timing of the service requests.
I will see if I can create a simpler test which isolates the problem. I suspect it will be possible to improve repeatability by adding more threads to the mix.
And yes I am running my tests on the latest AS trunk so the WS version is 3.3.0.Beta3
I am not sure it is the same bug as JBWS-2681. The problem there appears to happen when ports are created. This problem happens when two independently created ports are used.
It also seems to me to be different to JBWS-2192 which appears to relate to using a single port for a series of Async calls. However, I guess that depends upon what is going on under the covers. One interesting thing about this case is that the error manifests when I am invoking OneWay requests. Is there something similar about how these requests are excuted and the way Async requests get executed which might be causing te problem?
By the way, I didn't mention this in the preceding notes but I occasionally saw another intermittent and unpredictable error on the server side. My server code employs an injected WebServiceContext resource. Occasionally, the service call falls over with a null pointer exception when attempting to dereference the injected context. I don't know if this relates to the same problem or is some other issue. Anyway, it also appears to be related to the parallelism involved in this test. Could the problem be that the same service endpoint implementation instance is being entered in parallel below multiple service requests? 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?
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/526296#526296
14 years, 4 months