首页 > 解决方案 > 使用spring webclient时返回特定值时如何重试

问题描述

使用spring webclient时返回特定值时如何重试?我正在尝试使用 webclient 实现轮询方法。

public FooDto getFooDto(String token)
    return webClient
        .get()
        .uri(uriBuilder -> uriBuilder
            .path("/foo/{token}")
            .build(token))
        .retrieve()
        .bodyToMono(FooDto.class)
        .blockOptional()
        .repeatWhen() // ?? or retryWhen
            ...
            if (fooDto.getStatus().equals("processing")) {
                // request again
            }
            ...
        .orElseThrow(() -> new RuntimeException(""));

标签: reactjsspringwebclient

解决方案


推荐阅读