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

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.

主站蜘蛛池模板: 西昌市| 农安县| 翁牛特旗| 古浪县| 天气| 揭东县| 雷州市| 竹山县| 项城市| 襄汾县| 同仁县| 诸暨市| 葫芦岛市| 香格里拉县| 阿合奇县| 灵武市| 台东市| 永新县| 花莲县| 蒙城县| 枣强县| 金昌市| 瑞金市| 海原县| 阿尔山市| 宁德市| 始兴县| 广元市| 察隅县| 北京市| 阿巴嘎旗| 鹤岗市| 四子王旗| 交城县| 通辽市| 江油市| 蒙山县| 罗甸县| 元阳县| 临洮县| 县级市|