第一个单声道完成后致电单声道并返回第一个单声道的结果
我想在WebFlux环境中执行两个业务操作,仅在第一个操作成功之后,第二次操作才会发生。第二个完成后,我想返回第一个操作的结果。第二个操作称为org.springframework.web.reactive.function.client.webclient。这是我到目前为止尝试的:
public Mono<ResponseEntity<Resource>> callOperations(){
return service.operation1()
.flatMap(resource -> {
service.operation2();
return resource;
})
.map(ResponseEntity::ok);
}
当时我还尝试了并订阅,但是我无法让网络客户执行呼叫并返回service.operation.operation1。我该怎么办?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用反应式操作员构建流程,并让WebFlux订阅它。在您的片段中,没有订阅
service.operation2()
You need to construct a flow using reactive operators and let WebFlux subscribe to it. In your snippet there is no subscription to
service.operation2()
正确的成语正在调用 mono.delayuntil():
The correct idiom is calling Mono.delayUntil():
Your code is then as simple as: