UserPreferenceFlux 按优先级顺序保存用户偏好信息,我们必须考虑第二偏好,只有与第一偏好不匹配。首选项匹配需要阻塞 I/O 调用。我尝试使用以下代码,即使与用户第一偏好匹配,我也可以看到为第二偏好进行了 WebClient 调用,这是不必要的(因为第一匹配偏好已经在进行中)。
Flux<UserPreference> userPreferenceFlux = getUserPreferences();
UserPreferenceFlux
.flatMap(preference -> checkForMatch()) // Blocking IO call for match check
.filter(preference -> preference.isMatchFound())
.next(); // The Idea is to consider next preference if current preference is
// not found
ITMISS
相关分类