I am using spring-data-jpa
and spring webflux
. When i am extending my UserRepository with ReactiveCrudRepository
. i am getting below error:
org.springframework.dao.InvalidDataAccessApiUsageException: Reactive Repositories are not supported by DynamoDB. Offending repository is com.poc.crud.repository.EmployeeRepository!
If i extend with CrudRepository
and send response with Mono.just(data-from-db)
and Flux.just(data-from-db)
then every thing is fine.
My question is , How can i create a custom generic ReactiveCrudRepository<T,ID>
so that all crud method will return Mono and Flux objects.
If i extend with CrudRepository and send response with Mono.just(data-from-db) and Flux.just(data-from-db) then everything is fine.
Woah there - no, it's not. You might think it's all fine, but this is introducing blocking webcalls into a reactive chain, which will slow things down horrendously as soon as you have a few calls running in parallel. Worse than that, you've created a method that "looks" reactive, but isn't - commonly known as an "imposter reactive method".
Put simply, it's impossible to take blocking code and make it reactive - wrapping it in Mono.just()
doesn't work. The library has to be built asynchronously from the ground up.
The bad news is that, as far as I'm aware, there's currently (Nov 2019) no ReactiveCrudRepository
repository support for DynamoDB, so if you have to use this, you're a bit stuck.
The good news is that Amazon does now provide an asynchronous client for DynamoDB, and you can easily wrap a CompleteableFuture
in a Mono
by calling Mono.fromFuture()
- so you could use that to stay reactive and still have DynamoDB support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With