java Axis2 生成的存根线程安全吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1950080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 18:41:09  来源:igfitidea点击:

Are Axis2 generated stubs thread-safe?

javaweb-servicesmultithreadingthread-safetyaxis2

提问by BeeOnRope

Are client stubs generated from WSDL by Axis2 thread-safe?

Axis2 线程安全从 WSDL 生成客户端存根吗?

Of course, "thread-safe" isn't necessary a rigorously defined term, so I'm at least interested in the following:

当然,“线程安全”不一定是一个严格定义的术语,所以我至少对以下内容感兴趣:

Are differentinstances of the same stub class accessible concurrently by different threads, with the same effective behavior as single-threaded execution?

不同线程是否可以同时访问同一存根类的不同实例,并具有与单线程执行相同的有效行为?

Is a singleinstance 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.

您可能还希望使用此处描述的术语(以及源自此处)来更准确地讨论这一点。

回答by Stefan L

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.

我不确定axis2,但至少axis1 会生成非线程安全的客户端存根。我的印象是几乎所有其他 SOAP 客户端也是非线程安全的。如果我没记错的话,问题在于客户端存根以非线程安全的方式使用 XML 解析库。

Using apache commons-pooling to pool the instances and using each one from one thread at a time worked well though.

不过,使用 apache commons-pooling 来池化实例并从一个线程一次使用每个实例效果很好。

Update: For Axis2, see https://issues.apache.org/jira/browse/AXIS2-4357(claims Axis2 is not threadsafe, by design)

更新:对于 Axis2,请参阅https://issues.apache.org/jira/browse/AXIS2-4357(声称 Axis2 不是线程安全的,按照设计)

回答by Ravi Gupta

These stubs are stateless allowing reuse of the stub instances. Can you please elaborate on the problem you are facing with Axis2. People usually recommend Xfire over Axis.

这些存根是无状态的,允许重用存根实例。您能否详细说明您在使用 Axis2 时遇到的问题。人们通常会推荐 Xfire 而不是 Axis。

回答by BeeOnRope

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).

我想我会尝试通过提供我所做的进一步研究的一些更新来回答我自己的问题。看起来,默认情况下,较旧版本的 Axis2 存根可能只是“线程兼容”(不能从多个线程同时调用同一个存根实例 - 但可以调用不同的实例)。

See for example:

见例如:

http://markmail.org/message/3lu7x7pfo47vgnckhttp://markmail.org/message/sljyf6lpecxqllgx

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:

您可能会遇到一些套接字泄漏,如果不调用 cleanup/cleanupTransport,则套接字会用完,根据此线程和许多相关线程:

http://issues.apache.org/jira/browse/AXIS2-3670

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:

在某些情况下,至少底层 HttpClient 现在似乎是线程安全的,但根据您生成客户端的方式,整个存根可能不是:

http://amilachinthaka.blogspot.com/2009/05/improving-axis2-client-http-transport.html

http://amilachinthaka.blogspot.com/2009/05/improving-axis2-client-http-transport.html