java - 继续通过flux.fromStream进行迭代,即使在其中一个元素抛出异常之后
问题描述
public Mono<ResponseEntity<Data>> getData(@RequestParam List<String> tagIds){
Flux<S3Object> s3ObjectFlux = Flux.fromStream(tagIds.stream())
.parallel()
.runOn(Schedulers.boundedElastic())
.flatMap(id -> fetchResources(id)) //S3Exception is thrown here for one of the element
.sequential()
//here what should I use to catch the exception, log and continue
.ordered((u1, u2) -> u2.hashCode() - u1.hashCode());
Mono<Data> data = s3ObjectFlux.collectList()
.map(s3Objects -> new Data(s3Objects));
}
我正在遍历 tagIds 并在此处获取 s3 对象,如果该对象不存在或引发任何异常,我想记录,忽略它,然后继续下一步。所有 onError* 我都试过了,它只是打破了迭代,最后我得到了空列表
解决方案
推荐阅读
- python-3.x - 如何激活 virtualenv 并在 ansible 中安装包
- kotlin - 将 App Engine 连接到 Google 云 SQL 失败
- google-apps-script - 无法更新 Google 表格插件
- reactjs - 无法更改复选框状态
- algorithm - 图灵机算法
- azure-devops - 在 Azure DevOps 自托管代理上使用 Visual Studio 您必须为该代理购买付费许可证吗?
- typescript - 在 for ... in 循环中键入推理
- macros - 如何声明要在编辑器对话框中显示的图标?
- python - 如何加载子类keras模型
- geometry - QGIS消失缓冲区