V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
AerithLoveMe
V2EX  ›  问与答

关于 Spring Cloud Gateway 中异步的使用

  •  
  •   AerithLoveMe · Oct 27, 2022 · 1679 views
    This topic created in 1280 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
        1
    AerithLoveMe  
    OP
       Oct 27, 2022
    还是说这样本来就不好,应该把其它接口也做成基于 webflux 的?
    leafre
        2
    leafre  
       Oct 27, 2022
    现在没必要学这个,直接 k8s
    goofish
        3
    goofish  
       Oct 27, 2022
    响应式编程这玩意太复杂,你把握不住。有兴趣可以看看 Scala 里的 Future 和 web 框架 Play 是怎么写 web 接口的,Future 的功能比 java 强大很多
    yizmaoaa
        4
    yizmaoaa  
       Oct 27, 2022
    openfeign 是不支持 reactive 的,不过你可以使用 Spring 官方推荐的 https://github.com/PlaytikaOSS/feign-reactive

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