Jersey InvocationCallback Completed:使用哪个线程来调用这些方法

Jersey InvocationCallback Completed: Which thread is used to invoke these methods

我正在开发异步处理模块并实现了 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

查看 我知道这是调用异步回调选项的正确方法。

但是我无法理解哪个线程将用于调用回调选项? Jersey 是否使用 forkjoinpool.commonPool 来执行这些?

从 Jersey 源代码,它创建了一个基于线程池的线程池 属性

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);
}

在最新版本中使用了提供程序 https://github.com/eclipse-ee4j/jersey/blob/01c6a32a2064aeff2caa8133472e33affeb8a29a/core-client/src/main/java/org/glassfish/jersey/client/DefaultClientAsyncExecutorProvider.java