0
点赞
收藏
分享

微信扫一扫

Ribbon属性配置

夹胡碰 2022-02-15 阅读 90


Customizing the Ribbon Client by Setting Properties


Starting with version 1.2.0, Spring Cloud Netflix now supports customizing Ribbon clients by setting properties to be compatible with the Ribbon documentation.

This lets you change behavior at start up time in different environments.

The following list shows the supported properties>:

<clientName>.ribbon.NFLoadBalancerClassName: Should implement ILoadBalancer

<clientName>.ribbon.NFLoadBalancerRuleClassName: Should implement IRule

<clientName>.ribbon.NFLoadBalancerPingClassName: Should implement IPing

<clientName>.ribbon.NIWSServerListClassName: Should implement ServerList

<clientName>.ribbon.NIWSServerListFilterClassName: Should implement ServerListFilter

clientName是服务名称
 



To set the ​​IRule​​​ for a service name called ​​users​​, you could set the following properties:

application.yml

users:
ribbon:
NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList
NFLoadBalancerRuleClassName: com.netflix.loadbalancer.WeightedResponseTimeRule

​​Caching of Ribbon Configuration​​

Each Ribbon named client has a corresponding child application Context that Spring Cloud maintains. This application context is lazily loaded on the first request to the named client. This lazy loading behavior can be changed to instead eagerly load these child application contexts at startup, by specifying the names of the Ribbon clients, as shown in the following example:

application.yml

ribbon:
eager-load:
enabled: true # 下面这些client 在容器启动时加载
clients: client1, client2, client3


# see RibbonEagerLoadProperties







举报

相关推荐

java ribbon配置

0 条评论