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

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.

主站蜘蛛池模板: 佛学| 正蓝旗| 阜南县| 金堂县| 府谷县| 南开区| 探索| 泾阳县| 聂荣县| 出国| 浪卡子县| 峨眉山市| 广宁县| 永定县| 宜兰市| 昌都县| 武平县| 潞西市| 勐海县| 桃源县| 肃南| 上蔡县| 浙江省| 射洪县| 元江| 新沂市| 武宣县| 城固县| 塔河县| 江北区| 甘洛县| 宾阳县| 晋宁县| 南京市| 塘沽区| 米脂县| 仁化县| 连州市| 乾安县| 讷河市| 广宗县|