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

          主站蜘蛛池模板: 延津县| 达州市| 西峡县| 眉山市| 永定县| 延边| 惠州市| 中牟县| 洪泽县| 铁岭市| 梓潼县| 惠东县| 景洪市| 苗栗市| 南靖县| 南涧| 常熟市| 赤水市| 武邑县| 包头市| 鄱阳县| 博兴县| 建湖县| 闵行区| 济宁市| 乐陵市| 泰宁县| 汽车| 武清区| 开封县| 肥乡县| 泸西县| 甘南县| 沁源县| 黄大仙区| 湘西| 雷波县| 巫山县| 榕江县| 长宁区| 平原县|