我收到以下警告,然后出现一个 NPE,其中包含使用 CXF (2.5.2) 创建的、在 Jetty 上运行的服务。有人知道如何按照警告中的建议增加执行器队列大小吗?
org.apache.cxf.interceptor.OneWayProcessorInterceptor handleMessage
WARNING: Executor queue is full, run the oneway invocation task in
caller thread. Users can specify a larger executor queue to avoid
this.
WARNING: Interceptor for
{http://docs.oasis-open.org/wsn/bw-2}MyPublishService#{http://docs.oasis-open.org/wsn/bw-2}Notify
has thrown exception, unwinding now
java.lang.NullPointerException
at org.apache.cxf.jaxws.context.WrappedMessageContext.<init>(WrappedMessageContext.java:107)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:53)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:232)
at org.apache.cxf.interceptor.OneWayProcessorInterceptor.handleMessage(OneWayProcessorInterceptor.java:143)
...
更新:感谢接受的答案,我创建了一个包含以下 spring bean 的 xml 文件:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="cxf.default.workqueue" class="org.apache.cxf.workqueue.AutomaticWorkQueueImpl">
<property name="name" value="default" />
<property name="queueSize" value="512" />
</bean>
</beans>
最佳答案
它不容易配置(您需要将自己的 AutomaticWorkQueue
实例注册到应用程序的总线中)。处理 @OneWay
调用的最大线程数的默认值为 256,这意味着服务器最多可以同时处理 256 个 @OneWay
请求,而不会阻塞调用者线程。
在您的情况下,您可以创建一个 org.apache.cxf.workqueue.AutomaticWorkQueueImpl
类型的 spring bean,其具有属性 name="default"
并设置队列大小& 初始线程数、高低范围按照规范 http://grepcode.com/file/repo1.maven.org/maven2/org.apache.cxf/cxf-rt-core/2.1.4/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
关于java - 增加 CXF OneWayProcessorInterceptor 中的执行程序队列大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11195506/