官术网_书友最值得收藏!

Tolerance with MicroProfile config

As we saw in the previous sections, Fault Tolerance policies are applied by using annotations. For most use cases, this is enough, but for others, this approach may not be satisfactory because configuration is done at the source code level.

That's the reason why the parameters of MicroProfile Fault Tolerance annotations can be overridden using MicroProfile Config.

The annotation parameters can be overwritten via config properties using the following naming convention: <classname>/<methodname>/<annotation>/<parameter>.

To override maxDuration for @Retry on the doSomething method in the MyService class, set the config property like this:

org.example.microservice.MyService/doSomething/Retry/maxDuration=3000

If the parameters for a particular annotation need to be configured with the same value for a particular class, use the <classname>/<annotation>/<parameter> config property for configuration.

For instance, use the following config property to override all maxRetries for @Retry specified on the MyService class to 100:

org.example.microservice.MyService/Retry/maxRetries=100

Sometimes, the parameters need to be configured with the same value for the whole microservice (that is, all occurrences of the annotation in the deployment).

In this circumstance, the <annotation>/<parameter> config property overrides the corresponding parameter value for the specified annotation. For instance, to override all maxRetries for all of @Retry to be 30, specify the following config property:

Retry/maxRetries=30

This brings us to the end of discussion on Fault Tolerance in MicroProfile.

主站蜘蛛池模板: 临江市| 太原市| 平阳县| 枞阳县| 崇文区| 福鼎市| 喀喇| 西平县| 新巴尔虎右旗| 德兴市| 灵台县| 瑞金市| 勐海县| 怀仁县| 武汉市| 华池县| 太仆寺旗| 靖安县| 云浮市| 镶黄旗| 双城市| 芜湖县| 嘉定区| 长海县| 泗洪县| 宜春市| 呼伦贝尔市| 溧水县| 黔东| 阜康市| 仲巴县| 平顶山市| 万安县| 大安市| 永春县| 密云县| 中方县| 云林县| 镇远县| 望江县| 饶平县|