java - MongoDB 反应式无法发送完整的信号
问题描述
我正在使用spring webflux + mongodb。当返回一个合并多个通量的更复杂的方法时,我遇到了通量永远不会完成的问题(http 客户端被卡住等待)。
在尝试重现时,以下似乎是问题:
someRepository.findAll().subscribe([etc...]); 尽管数据库中有 15228 个实体,但总是准确地发出 3855 个实体。未播放完整信号。当使用 coreSubscriber 时,订阅者将在 gc 运行时被垃圾收集,这意味着基本上没有任何东西仍在排队。
有谁知道这个问题的原因和/或解决方法?
(测试在 spring-boot-starter-data-mongodb-reactive 2.0.0.RELEASE、2.0.3.RELEASE 和 2.0.4.RELEASE 版本中 100% 发生,假设也发生在中间版本中。Mongo版本:4.0.0)
编辑:相关代码:
public interface LocationRepository extends ReactiveMongoRepository<Location, String> {}
和
locationRepository.findAll().subscribe(result -> log.info("RESULT "+result), error -> log.info("ERROR"+error),() -> log.info("DONE"));
解决方案
后来证明这是驱动程序中的死锁。这可以通过在配置mongo时使用AsynchronousSocketChannelStreamFactoryFactory来解决
推荐阅读
- android - 使用 java 应用程序实现 kotlin 模块产生 java.lang.NoClassDefFoundError: 资源类解析失败
- javascript - 使用辅助函数时未传递 Javascript 值
- html5-canvas - 在复杂的 HTML 画布形状周围(和内部)描边?
- database - 时空数据库/数据处理框架
- c# - DataTrigger 未在 DataGrid 中触发
- wordpress - 使用 Chart.js 从表单字段中绘制图形
- javascript - 如何为这些问题拍照
- bluetooth - 无法连接树莓派 Pi3B 蓝牙到 HC-06 模块?
- firebase - 访问 RemoteConfig 创建循环 Flutter Web
- java - 为什么余数函数没有给我Java中的确切余数