我有点陷入一个琐碎的任务:每当我使用反应式 Spring WebClient 查询外部 API 或查询反应式 MongoDBRepository 时,我想记录有多少实体通过了我的 Flux,例如。记录诸如“在数据库中找到 n 条记录”之类的消息。例如:
return repository.findAll()
.doOnComplete { log.info("Found total n records!") } // how to get the n?
.filter { it.age > 10 }
.distinct { it.name }
Run Code Online (Sandbox Code Playgroud)
TLDR:完成后如何获取通量大小(也许还有它的内容)?