Jersey InvocationCallback已完成:使用哪个线程来调用这些方法 [英] Jersey InvocationCallback Completed: Which thread is used to invoke these methods
问题描述
我正在研究异步处理模块和已实现的Jersey调用回调.
I am working on a Async Processing Module and Implemented Jersey Invocation Callback.
我的实现很简单,并且正在定义Completed和Failed方法,如 https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/InvocationCallback.html
My implementation is straight forward and am defining a Completed and Failed methods as mentioned in 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
查看在jersey中正确处理后台呼叫这是调用异步回调选项的正确方法.
Looking into Correct handling of background calls in jersey I understand this is the correct way to invoke the async call back options.
但是无法理解将使用哪个线程来调用回调选项?泽西岛是否使用forkjoinpool.commonPool执行这些操作?
However am not able to understand which thread would be used to invoke the callback options? Does Jersey uses forkjoinpool.commonPool to execute these?
推荐答案
从Jersey源代码开始,它基于threadpool属性创建线程池
From Jersey source code, it creates a thread pool based on the threadpool property
jersey.config.client.async.threadPoolSize
jersey.config.client.async.threadPoolSize
passed,默认为0
passed , defaulting to 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);
}
In latest version a provider is used https://github.com/eclipse-ee4j/jersey/blob/01c6a32a2064aeff2caa8133472e33affeb8a29a/core-client/src/main/java/org/glassfish/jersey/client/DefaultClientAsyncExecutorProvider.java
这篇关于Jersey InvocationCallback已完成:使用哪个线程来调用这些方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!