You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2021/06/04 02:30:12 UTC

[dubbo-website] branch master updated: 重试次数配置.md (#806)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 696b6ca  重试次数配置.md (#806)
696b6ca is described below

commit 696b6ca27708c4633d2d79bf8ce078038e1bda3d
Author: shanwb <sh...@sina.cn>
AuthorDate: Fri Jun 4 10:30:04 2021 +0800

    重试次数配置.md (#806)
---
 ...254\241\346\225\260\351\205\215\347\275\256.md" | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git "a/content/zh/docs/v2.7/user/examples/\351\207\215\350\257\225\346\254\241\346\225\260\351\205\215\347\275\256.md" "b/content/zh/docs/v2.7/user/examples/\351\207\215\350\257\225\346\254\241\346\225\260\351\205\215\347\275\256.md"
new file mode 100644
index 0000000..ac98396
--- /dev/null
+++ "b/content/zh/docs/v2.7/user/examples/\351\207\215\350\257\225\346\254\241\346\225\260\351\205\215\347\275\256.md"
@@ -0,0 +1,29 @@
+---
+type: docs
+title: "重试次数配置"
+linkTitle: "重试次数配置"
+weight: 1
+description: >-
+     配置dubbo服务重试次数.
+--- 
+Dubbo 服务在尝试调用一次之后,如出现非业务异常(服务突然不可用、超时等),Dubbo 默认会进行额外的最多2次重试.
+
+重试次数支持两种自定义配置: 1.通过注解/xml进行固定配置;2.通过上下文进行运行时动态配置
+
+
+## 示例
+
+通过注解/xml进行固定配置
+
+```xml
+<dubbo:consumer retries="2"></dubbo:consumer>
+```
+
+通过RpcContext进行运行时动态配置,优先级高于注解/xml进行的固定配置(两者都配置的情况下,以RpcContext配置为准).
+
+```Java
+// dubbo服务调用前,通过RpcContext动态设置本次调用的重试次数
+RpcContext rpcContext = RpcContext.getContext();
+rpcContext.setAttachment("retries", 5);
+
+```