This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 1d058191f6 [type:fix] support dubbo method configure (#5891)
1d058191f6 is described below
commit 1d058191f632278d2b3bf2823e55a193029d1e6b
Author: eye-gu <[email protected]>
AuthorDate: Tue Jan 14 11:50:00 2025 +0800
[type:fix] support dubbo method configure (#5891)
Co-authored-by: aias00 <[email protected]>
---
.../apache/dubbo/ApacheDubboServiceBeanListener.java | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git
a/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java
b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java
index 17a884972b..8c2378a409 100644
---
a/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java
+++
b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java
@@ -45,6 +45,7 @@ import org.springframework.util.ReflectionUtils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -201,7 +202,7 @@ public class ApacheDubboServiceBeanListener extends
AbstractContextRefreshedEven
.ruleName(ruleName)
.pathDesc(desc)
.parameterTypes(parameterTypes)
- .rpcExt(buildRpcExt(bean))
+ .rpcExt(buildRpcExt(bean, methodName))
.rpcType(RpcTypeEnum.DUBBO.getName())
.enabled(shenyuClient.enabled())
.namespaceId(namespaceId)
@@ -219,7 +220,7 @@ public class ApacheDubboServiceBeanListener extends
AbstractContextRefreshedEven
}).orElse(port);
}
- private String buildRpcExt(final ServiceBean<?> serviceBean) {
+ private String buildRpcExt(final ServiceBean<?> serviceBean, final String
methodName) {
DubboRpcExt build = DubboRpcExt.builder()
.protocol(StringUtils.isNotEmpty(serviceBean.getProtocol().getName()) ?
serviceBean.getProtocol().getName() : "")
.group(StringUtils.isNotEmpty(serviceBean.getGroup()) ?
serviceBean.getGroup() : "")
@@ -231,6 +232,16 @@ public class ApacheDubboServiceBeanListener extends
AbstractContextRefreshedEven
.cluster(StringUtils.isNotEmpty(serviceBean.getCluster()) ?
serviceBean.getCluster() : Constants.DEFAULT_CLUSTER)
.url("")
.build();
+ // set method config: loadbalance,retries,timeout,sent
+
Optional.ofNullable(serviceBean.getMethods()).orElse(Collections.emptyList()).stream()
+ .filter(m -> methodName.equals(m.getName()))
+ .findFirst()
+ .ifPresent(methodConfig -> {
+
Optional.ofNullable(methodConfig.getLoadbalance()).filter(StringUtils::isNotEmpty).ifPresent(build::setLoadbalance);
+
Optional.ofNullable(methodConfig.getRetries()).ifPresent(build::setRetries);
+
Optional.ofNullable(methodConfig.getTimeout()).ifPresent(build::setTimeout);
+
Optional.ofNullable(methodConfig.getSent()).ifPresent(build::setSent);
+ });
return GsonUtils.getInstance().toJson(build);
}
}