Closed vavisha closed 1 year ago
This isn't a Spring Data issue, it relates to the netty event loop. Each connection is associated with a unique event loop Thread and if you use the same R2DBC connection (you can check the PID), then your code hits the same thread which is the most efficient way of working.
Unless you concurrently use multiple connections, you won't see that other IO threads will be utilized.
Versions
Current Behavior
After the reactive repository (R2dbcRepository), operators are executed in one thread (reactor-tcp-nio-1) out of 10 available
Table schema
simple example app with docker-compose.yml in zip file : r2dbc.zip log: r2dbc.log
Code
```java package com.example; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class R2DBCApplication { private static final Logger log = LoggerFactory.getLogger(R2DBCApplication.class); public static void main(final String[] args) { SpringApplication.run(R2DBCApplication.class, args); } } ``` ```java package com.example; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Mono; import java.util.UUID; @RestController public class ValueController { private static final Logger log = LoggerFactory.getLogger(ValueController.class); @Autowired private ValueRepository repository; @GetMapping("/value") public MonoSteps to reproduce
result: breakpoint won't hit a second time (reactor-tcp-nio-1 stopped, second connection wait while reactor-tcp-nio-1 release)
Expected behavior
After the reactive repository (R2dbcRepository), operators are executed in separated r2dbc's threads/workers (thread per connection, e.g. reactor-tcp-nio-1 and reactor-tcp-nio-2)