Are client stubs generated from WSDL by Axis2 thread-safe?
Of course, "thread-safe" isn't necessary a rigorously defined term, so I'm at least interested in the following:
Are different instances of the same stub class accessible concurrently by different threads, with the same effective behavior as single-threaded execution?
Is a single instance of the same stub class accessible concurrently by different threads, with the same effective behavior as the same calls interleaved in some arbitrary way in single-threaded execution?
You may also wish to use the terminology described here (and originating here) to discuss this more precisely.
I'm not sure about axis2, but at least axis1 generates non-threadsafe client stubs. I got the impression pretty much every other SOAP client was non-threadsafe as well. If I remember correctly the issue was with the XML parsing library being used in a non-threadsafe way by the client stub.
Using apache commons-pooling to pool the instances and using each one from one thread at a time worked well though.
Update: For Axis2, see https://issues.apache.org/jira/browse/AXIS2-4357 (claims Axis2 is not threadsafe, by design)
I guess I'll try to answer my own question by providing some update on futher research I did. It appears that by default older versions of Axis2 stubs may have been only "thread-compatible" (cannot make calls on the same stub instance concurrently from multiple threads - but calls to different instances is OK).
See for example:
http://markmail.org/message/3lu7x7pfo47vgnck http://markmail.org/message/sljyf6lpecxqllgx
You may experience some socket leaks, and run out of sockets if you don't call cleanup/cleanupTransport, as per this thread and many related ones:
http://issues.apache.org/jira/browse/AXIS2-3670
In some cases, at least the underlying HttpClient now seems to be thread-safe, but depending on how you generated your client, the entire stub might not be:
http://amilachinthaka.blogspot.com/2009/05/improving-axis2-client-http-transport.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With