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 閱讀(588) 評論(0)  編輯  收藏 所屬分類: SPRING CLOUDREACTIVE STREAMS

          主站蜘蛛池模板: 昭苏县| 花垣县| 阳东县| 会同县| 扶沟县| 龙游县| 页游| 新宁县| 盐山县| 土默特右旗| 舒兰市| 大石桥市| 濮阳县| 海南省| 剑川县| 乃东县| 雷山县| 咸宁市| 黄平县| 贺州市| 广饶县| 东阿县| 根河市| 兰西县| 荣成市| 锡林郭勒盟| 安福县| 张掖市| 凤山县| 城市| 灵山县| 阿城市| 临沧市| 巴彦淖尔市| 婺源县| 北宁市| 岑溪市| 黔江区| 仙居县| 甘肃省| 安吉县|