超全模态模型 × Harness 升级,升级解锁 ArkClaw,最新支持 DeepSeek-V4 系列与 GLM-5.1
Hey there! I totally get the frustration of having to bridge reactive code with a stubborn blocking API—we’ve all been stuck in that spot. Let’s walk through how to properly flatten that nested reactive structure without hitting the dreaded "block() is not supported" error.
Mono
First, we need to resolve all the inner Mono<Object> values within the map without blocking inside the reactive thread. We can do this by leveraging Reactor’s operators to handle the nested reactivity within the stream:
Mono<Object>
Mono<Map<String, Object>> flattenedData = resolvedData.flatMap(outerMap -> { // Convert the map entries into a Flux to process each one individually Flux<Map.Entry<String, Object>> resolvedEntries = Flux.fromIterable(outerMap.entrySet()) .flatMap(entry -> // Resolve the inner Mono<Object> and pair it with its original key entry.getValue().map(value -> Map.entry(entry.getKey(), value)) ); // Collect all resolved entries back into a single Map return resolvedEntries.collectMap(Map.Entry::getKey, Map.Entry::getValue); });
Let me break this down simply:
flatMap
Map<String, Mono<Object>>
Flux
collectMap
Map
Now, if you absolutely need a synchronous Map<String, Object> to pass to your non-reactive method, you need to make sure the block() call happens on a thread designed for blocking work. Reactor’s boundedElastic scheduler is made for this—it manages a pool of threads dedicated to blocking operations, so you won’t block the reactive event loop threads that cause that error:
Map<String, Object>
block()
boundedElastic
// Get the synchronous map safely Map<String, Object> finalResult = flattenedData .subscribeOn(Schedulers.boundedElastic()) .block();
Mono.fromCallable()
内容的提问来源于stack exchange,提问作者mattbertolini
超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起
模型再升级,30秒超长叙事, 模态参考扩容
模型自由,工具不限,最新支持 Deepseek-V4 系列、GLM-5.3 系列
超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列
大模型19元起,Al应用9.9元畅享,新人首购爆款尽享优惠