美文网首页
2020-07-03--openfegin

2020-07-03--openfegin

作者: 李霖神谷 | 来源:发表于2020-07-03 14:57 被阅读0次

1.什么是openfegin:声明式的web服务的客户端。之前是在消费者服务器中通过reestTemplate和ribbon对生产者服务进行负载调用。现在只需要在接口上配置对应的注解,并在启动类上添加启动的注解即可。

@Component
@FeignClient(value = "SPRING-CLOUD-PAYMENT")
public interface FindConsume {
    @GetMapping(value = "/find")
    R find(@RequestParam(value = "goodId")  Integer goodId);
}




@SpringBootApplication
@EnableFeignClients
public class ConsumerFeginApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerFeginApplication.class,args);
    }

}

2.openfegin的网络延迟时间设置与后端业务逻辑处理时间设置
模拟时间超时

   @GetMapping(value = "/timeOut")
    public  String timeOut(){
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return  "ok";
    }
}

在订单服务中添加配置
ribbon:
  ReadTimeout: 5000
  ConnectTimeout: 5000

3.fegin自带日志管理。

选择Full级别的日志
@Configuration
public class feginConfig {
    @Bean
    public Logger.Level logger(){
        return  Logger.Level.FULL;
    }
}


配置文件设置书写日志的包的地址

logging:
  level:
     com.shuai.service.FindConsume: debug

相关文章

  • 2020-07-03--openfegin

    1.什么是openfegin:声明式的web服务的客户端。之前是在消费者服务器中通过reestTemplate和r...

网友评论

      本文标题:2020-07-03--openfegin

      本文链接:https://www.haomeiwen.com/subject/jilsqktx.html