paulwong

          SPRING CLOUD - REACTIVE FEIGN

          目前SPRING CLOUD(2020)尚未支持REACTIVE FEIGN,但官方推薦使用feign-reactive。

          pom.xml
          <dependency>
              <groupId>com.playtika.reactivefeign</groupId>
              <artifactId>feign-reactor-spring-cloud-starter</artifactId>
              <version>3.1.2</version>
              <type>pom</type>
          </dependency>


          LoanDecisionClientReactive.java
          package com.paul.testspringcloudstream.loancheck.service;

          import org.springframework.web.bind.annotation.PostMapping;
          import org.springframework.web.bind.annotation.RequestBody;

          import com.paul.testspringcloudstream.common.model.Loan;

          import reactivefeign.spring.config.ReactiveFeignClient;
          import reactor.core.publisher.Mono;

          @ReactiveFeignClient(name = "loan-decision")
          public interface LoanDecisionClientReactive {
              
              @PostMapping("/loan-decision")
              public Mono<Loan> getDecision(@RequestBody Loan loan);

          }

          LoanCheckConfiguration.java
          @Configuration
          @Import({
              MongoDbConsumerConfiguration.class,
          })
          @EnableDiscoveryClient
          @EnableReactiveFeignClients("com.paul.testspringcloudstream.loancheck.service")
          public class LoanCheckConfiguration {
          }


          使用同feign
          @Autowired
          private LoanDecisionClientReactive loanDecisionClientReactive;

          Reference
          https://blog.csdn.net/LCBUSHIHAHA/article/details/113817966

          官方SAMPLE
          https://github.com/kptfh/feign-reactive-sample

          posted on 2021-12-01 16:45 paulwong 閱讀(594) 評論(0)  編輯  收藏 所屬分類: SPRING CLOUD 、REACTIVE STREAMS

          主站蜘蛛池模板: 甘泉县| 乐东| 城口县| 秭归县| 东方市| 济南市| 靖边县| 松阳县| 维西| 洪江市| 曲阳县| 开原市| 玉田县| 大关县| 哈密市| 彰武县| 尚义县| 庆城县| 惠水县| 昌江| 海兴县| 黄龙县| 建始县| 张家界市| 怀宁县| 南开区| 蒙自县| 崇义县| 广宗县| 西林县| 大化| 邵阳县| 长白| 辽阳市| 阳朔县| 曲阳县| 汤原县| 河北区| 常熟市| 邛崃市| 英吉沙县|