All Questions
Tagged with virtual-threads spring-boot
35 questions
1
vote
1
answer
56
views
Virtual Threads in Spring Integration for long-running external service calls
We are currently working on a Spring Integration flow where each incoming message needs to trigger a call to an external HTTP service. The external call can take up to 20 seconds to complete, and the ...
6
votes
2
answers
165
views
Using ScopedValue instead of ThreadLocal in Servlet Filter in spring boot app
Our application heavily uses ThreadLocals where we read values from ServletRequest parameters and provide theses as a global context on Thread Level to other Services.
Something like this:
@Component
@...
5
votes
2
answers
516
views
Spring boot with java 21 virtual threads - is there a way to terminate gracefully?
In SB 3.4 + java 21, when you terminate the java process, regardless of type of task executor, it will wait till all threads finish, which will include scheduled jobs as well as API calls.
However, if ...
5
votes
1
answer
343
views
Using toFuture in Spring webClient when using virtual threads
I've been trying to implement an orchestration system using VirtualThreads.
So far, I understand the underlying problems that I may face, and the one that really concerns me is "pinning."
I'...
1
vote
1
answer
171
views
micrometer Instrumentation of Thread Switching Components for Executors.newVirtualThreadPerTaskExecutor() with for loop
I have the following piece of code:
@PostMapping("/question")
public String question(@RequestBody List<String> messages) {
try (ExecutorService executor = Executors....
3
votes
1
answer
795
views
How do I verify that Virtual Threads are being used in my Spring Boot microservice?
Libraries used by my microservice, running on JDK 21
Spring Boot 3.4.1
Spring Cloud 2024.0.0
Spring Cloud AWS 3.3.0-RC1
I have set spring.threads.virtual.enabled=true in my Spring Boot microservice, ...
1
vote
0
answers
364
views
SpringBoot 3.4 with virtual thread enabled, but getting sequential execution
In my Spring Boot 3.4 and Java 21 based application, I have enabled virtual threads via:
spring.threads.virtual.enabled=true
I am using Spring Boot 3.4:
<groupId>org.springframework.boot</...
0
votes
0
answers
195
views
Graceful shutdown Spring Boot virtual thread
Spring Boot offers graceful shutdown but only for container(Tomcat). Since I also want my tasks are graceful shutdown, I set up my ThreadPoolTaskExecutor to:
// Initialize ThreadPoolTaskExecutor
...
0
votes
0
answers
301
views
How to build restful API using virtual threads
With the introduction of virtual threads since Java 21, it seems like it will become the future to use instead of the reactive model (ref. Do Java 21 virtual threads address the main reason to switch ...
2
votes
1
answer
923
views
Oh no! IO! Concurrency issues with virtual threads, HikariCP, and Spring Boot JDBC (Postgres)
I have run into an issue when using the following technologies.
PostgreSQL run through a docker container
Project Loom
Spring Boot 3.3.4
Java 21
Spring Boot Starter JDBC (which includes HikariCp - ...
4
votes
1
answer
801
views
Cannot limit the concurrency of servlet requests using Spring Boot virtual threads with Tomcat
I am updating a Kotlin (v1.9.25) Spring Boot (v3.3.1) project from Java 17 to Java 21 in order to enable Virtual Threads.
In our service, almost all requests acquire one database connection and hold ...
7
votes
1
answer
3k
views
Spring Boot application gets stuck when virtual threads are used on Java 21
I've run into an issue related to performance of Spring Boot 3 application with virtual threads enabled.
TL;DR reproduction steps:
Checkout https://github.com/stsypanov/concurrency-demo
Run ...
1
vote
1
answer
2k
views
Virtual Threads Not Being Used in Spring Boot 3.2 Application Despite Configuration
I'm currently working on a Spring Boot 3.2 application with Java 21, and I've enabled virtual threads for improved performance. However, I’m noticing that many platform threads are still being created,...
0
votes
0
answers
301
views
InterruptedException causing application restart after running virtual threads for a few days
I'm encountering an issue with my application, which uses zulu-openjdk:21. To manage threads more efficiently, I encapsulated a method to wait for multiple threads to complete:
public static void ...
0
votes
0
answers
343
views
Spring Boot Virtual Threads pinning with ActiveMQ Classic
I am on Spring Boot 3.2.5 with virtual threads enabled and connecting to an external ActiveMQ Classic broker using the ActiveMQ 5.18.4 client. I am using the JmsTemplate sendAndReceive() method to ...