Skip to content

Commit ae775d8

Browse files
committed
Adding special note on virtual threads usage
1 parent e2daa2d commit ae775d8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/thread-safety.adoc

+7
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ Note that `SimpleThreadScope` does not destroy beans that have a destruction int
1717
IMPORTANT: By default, the application context's event multicaster invokes event listeners on the calling thread.
1818
If you change the multicaster to use an async executor, thread cleanup is not effective.
1919

20+
== Special Note on Virtual Threads and Concurrent Message Listener Containers
21+
22+
Because of certain limitations in the underlying library classes still using `synchronized` blocks for thread coordination, applications need to be cautious when using virtual threads with concurrent message listener containers.
23+
When virtual threads are enabled, if the concurrency exceeds the available number of platform threads, it is very likely for the virtual threads to be pinned on the platform threads and possible race conditions.
24+
Therefore, as the 3rd party libraries that Spring for Apache Kafka uses evolves to fully support virtual threads, it is recommended to keep the concurrency on the message listener container to be equal to or less than the number of platform threads.
25+
This way, the applications avoid any race conditions between the threads and the virtual threads being pinned on platform threads.
26+

0 commit comments

Comments
 (0)