I wanted to use reactive spring to index data from a SQL Server database (using R2DBC) to Elasticsearch (using reactive Elasticsearch). I have an entity class corresponding to the table in SQL Server and I have a model class corresponding to the documents which will be indexed by Elasticsearch.
For both databases (SQL Server & Elasticsearch), I have created repositories:
Repository for SQL Server:
@Repository
public interface ProductRepository extends ReactiveCrudRepository<ProductTbl, Long> {
}
Repository for Elasticsearch:
@Repository
public interface ProductElasticRepository extends ReactiveElasticsearchRepository<Product, String> {
}
Shouldn't I be able to index all documents by calling productElasticRepository.saveAll(productRepository.findAll())
?
It doesn't quite work. Either it exceeds the DataBufferLimit and therefore throws an Exception or there is a ReadTimeOutException. When executing, I can see R2DBC creating RowTokens for each data entry of the SQL Server database. However a POST to the Elasticsearch client does only occur until all rows are obtained, which doesn't seem to be how reactive code should work? I am definitely missing something here and hope someone can help.