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 Wan Luo <wa...@gmail.com> on 2005/11/01 22:55:19 UTC

[Axis2] Is Axiom Thread-Safe?

This is related to a previous thread, but I seperated it incase other people
have the same question.

I would like to use Axiom to parse SOAP requests on the server side. Is
Axiom Thread safe? I could not find any clues in the documentation.

if not, how do I make it thread-safe? Parser Pool, parser per thread
(expensive)? Is there a modular component built in to Axis to handle parsing
soap requests in a multi-threaded environment?

Re: [Axis2] Is Axiom Thread-Safe?

Posted by Eran Chinthaka <ch...@opensource.lk>.
Hmm Good question  ;-) .

I just wrote a test case to test one aspect of this issue. Using a
thread I read a XML file, built OM and serialize that to a String and
compared that with the original file. I ran this thread 100 times
without a problem and the test and the comparison was successful.

But there is another aspect of this. What if different threads are
accessing the same OMElement ? This we haven't tested. As far as Axis2
is concerned, there is a rare chance for this to happen. When Axis
servlet receives a message, we create and manipulate the SOAP envelope
in the same thread, usually. So the second aspect doesn't affect Axis2.

But if you want to use AXIOM in a separate environment and wanna achieve
thread safe, you better need some testing. I haven't  tried that.

-- Chinthaka

Wan Luo wrote:

>This is related to a previous thread, but I seperated it incase other people
>have the same question.
>
>I would like to use Axiom to parse SOAP requests on the server side. Is
>Axiom Thread safe? I could not find any clues in the documentation.
>
>if not, how do I make it thread-safe? Parser Pool, parser per thread
>(expensive)? Is there a modular component built in to Axis to handle parsing
>soap requests in a multi-threaded environment?
>
>  
>


Re: [Axis2] Is Axiom Thread-Safe?

Posted by Eric Johnson <er...@tibco.com>.
I think the answer is a simple "no."

None of the other XML tree APIs are thread safe either, so far as I know.

Thread safety is a tricky thing to do across a "tree" model, as 
insert/remove of an element can affect as many as three nodes (in a DOM 
or AXIOM impl).  It is difficult to synchronize on anything reasonable 
that makes this work, at least as far as I've thought through the problem.

Maybe your point is subtler, though?  AXIOM, as you probably know, is 
constructed on the fly from a StAX stream.  Perhaps you mean that 
multiple threads should be able to simultaneously read an 
as-yet-not-fully-parsed AXIOM tree, and it should all work "correctly", 
regardless of where the various threads try to traverse?

-Eric.

Wan Luo wrote:

> This is related to a previous thread, but I seperated it incase other 
> people have the same question.
>
> I would like to use Axiom to parse SOAP requests on the server side. 
> Is Axiom Thread safe? I could not find any clues in the documentation.
>
> if not, how do I make it thread-safe? Parser Pool, parser per thread 
> (expensive)? Is there a modular component built in to Axis to handle 
> parsing soap requests in a multi-threaded environment?