Skip to content

Virtual thread not being used while using verticle deployed as ThreadingModel.VIRTUAL_THREAD in vertx httpclient #5816

@himanshumps

Description

@himanshumps

Version

5.0.5

Context

When I use vertx threading model as eventloop or worker while using vertx httpclient, the callbacks are properly coming back on eventloop or worker respectively. However, when I use threading model as virtual thread, the callback are on event loop.

Steps to reproduce

Deploy a verticle with threading model as virtual thread and create a httpclient in the start/constructor method. Enable the log statements in code below to check the threads on which callback is happening.

Sample code:

//log.info("Thread name: {}", Thread.currentThread().getName());
httpClient
      .request(requestToBeSent.requestOptions())
      .compose(httpClientRequest -> {
        //log.info("Compose thread name: {}", Thread.currentThread().getName());
        if (requestToBeSent.body() == null) {
          return httpClientRequest.send();
        } else {
          return httpClientRequest.send(requestToBeSent.body());
        }
      })
      .onComplete(httpResponse -> {
        //log.info("Complete thread name: {}", Thread.currentThread().getName());
        if (httpResponse.failed() && httpResponse.cause() != null) {
          log.error("Issue while getting the response after sending the request.", httpResponse.cause());
        }
      });

Do you have a reproducer?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions