Does coroutine change spring boot from 1 thread per request to multiple request per thread?

Viewed 31

I am a newbie to reactive or coroutine concepts. We are trying to see if we can use Kotlin coroutine to achieve multiple requests per thread model in Spring boot. And we are using webflux starter with reactor netty.

We use CoroutineCrudRepository for the data layer and use suspend functions in the controller and service layers so the application is fully running with coroutines.

Still I feel there is a missing bit to make it possible to handle multiple requests from a single thread in spring boot

Below are some code snippets.

Controller

 override fun getProductLists(
    countryCode: String, customerId: String
): ResponseEntity<Flow<ProductListDto>> {
    return productListService.getProductLists(countryCode, customerId)


Service layer 

fun getProductLists(countryCode: String, customerId: String): Flow<ProductListDto> {
    return bookmarkDao.findByCountryCodeCustomerId(countryCode,customerId)
}

DAO layer
interface BookmarkDao : CoroutineCrudRepository<ProductListDto, UUID>  {
 fun findByCountryCodeCustomerId(cc: String, customerId: String):Flow<ProductListDto>
}

 

Are there more things to be done in order to achieve what am looking for thanks a lot.

0 Answers
Related