如何解决Jersey InvocationCallback Completed:使用哪个线程来调用这些方法
我正在研究异步处理模块并实现 Jersey 调用回调。
我的实现很简单,我定义了一个 Completed 和 Failed 方法,如中所述 https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/InvocationCallback.html
并按照 https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/async.html#d0e10417
查看 Correct handling of background calls in jersey 我知道这是调用异步回调选项的正确方法。
但是我无法理解将使用哪个线程来调用回调选项? Jersey 是否使用 forkjoinpool.commonPool 来执行这些?
解决方法
从 Jersey 源代码,它基于 threadpool 属性创建了一个线程池
jersey.config.client.async.threadPoolSize
通过,默认为0
public ClientRuntime(ClientConfig config,Connector connector,ServiceLocator locator) {
Builder<ClientRequest> requestingChainBuilder = Stages.chain((Function)locator.createAndInitialize(RequestProcessingInitializationStage.class));
int asyncThreadPoolSize = (Integer)PropertiesHelper.getValue(config.getProperties(),"jersey.config.client.async.threadPoolSize",0);
asyncThreadPoolSize = asyncThreadPoolSize < 0 ? 0 : asyncThreadPoolSize;
this.asyncExecutorsFactory = new ClientAsyncExecutorFactory(locator,asyncThreadPoolSize);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。