AerithLoveMe
V2EX  ›  问与答

关于 Spring Cloud Gateway 中异步的使用

  •  
  •   AerithLoveMe · Oct 27, 2022 · 2249 views
    This topic created in 1485 days ago, the information mentioned may be changed or developed.
    最近使用 Spring Cloud Gateway 搭建了个网关学习学习,请问如果我想在过滤器中调用内部其它 restful 接口,最佳实践是什么?

    如果我直接用 openfeign 调用传统基于 servlet 的接口(比如进行权限相关的校验),IDE 都会提示不要在 webflux 中使用阻塞式调用,那请问各位应该怎么做呢?

    刚刚学习响应式,很多都不是很懂,希望大佬不吝赐教。
    5 replies  •  2022-10-27 14:35:26 +08:00
    AerithLoveMe
    AerithLoveMe
    OP
    Oct 27, 2022
    1
    还是说这样本来就不好,应该把其它接口也做成基于 webflux 的?
    leafre
    leafre
    Oct 27, 2022
    2
    现在没必要学这个,直接 k8s
    goofish
    goofish
    Oct 27, 2022
    3
    响应式编程这玩意太复杂,你把握不住。有兴趣可以看看 Scala 里的 Future 和 web 框架 Play 是怎么写 web 接口的,Future 的功能比 java 强大很多
    yizmaoaa
    yizmaoaa
    Oct 27, 2022
    4
    openfeign 是不支持 reactive 的,不过你可以使用 Spring 官方推荐的 https://github.com/PlaytikaOSS/feign-reactive

    这个库,这个库也不是重新写的,只是在 openfeign 的基础上包了一层 reactive 的。
    taixujianyi
    taixujianyi
    Oct 27, 2022
    5
    可以用 spring-webflux 中的 org.springframework.web.reactive.function.client.WebClient 进行调用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   980 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 19:11 · PVG 03:11 · LAX 11:11 · JFK 14:11
    ♥ Do have faith in what you're doing.