-
Notifications
You must be signed in to change notification settings - Fork 562
/
spring-consumer.xml
90 lines (84 loc) · 5.14 KB
/
spring-consumer.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015 The Jupiter Project
~
~ Licensed under the Apache License, version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at:
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jupiter="http://www.jupiter-rpc.org/jupiter"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.jupiter-rpc.org/jupiter
http://www.jupiter-rpc.org/jupiter/jupiter.xsd">
<bean id="globalInterceptor1" class="org.jupiter.example.spring.interceptor.consumer.MyGlobalConsumerInterceptor1" />
<bean id="globalInterceptor2" class="org.jupiter.example.spring.interceptor.consumer.MyGlobalConsumerInterceptor2" />
<jupiter:client id="jupiterClient" registryType="default">
<jupiter:property registryServerAddresses="127.0.0.1:20001" />
<jupiter:property globalConsumerInterceptors="globalInterceptor1,globalInterceptor2" />
<!-- 可选配置 -->
<!--
String registryServerAddresses // 注册中心地址 [host1:port1,host2:port2....]
String providerServerAddresses // IP直连到providers [host1:port1,host2:port2....]
ConsumerInterceptor[] globalConsumerInterceptors; // 全局拦截器
-->
<!-- 网络层配置选项 -->
<jupiter:netOptions>
<jupiter:childOption SO_RCVBUF="8192" />
<jupiter:childOption SO_SNDBUF="8192" />
<jupiter:childOption ALLOW_HALF_CLOSURE="false" />
</jupiter:netOptions>
</jupiter:client>
<bean id="interceptor1" class="org.jupiter.example.spring.interceptor.consumer.MyConsumerInterceptor1" />
<bean id="interceptor2" class="org.jupiter.example.spring.interceptor.consumer.MyConsumerInterceptor2" />
<!-- consumer -->
<jupiter:consumer id="serviceTest" client="jupiterClient" interfaceClass="org.jupiter.example.ServiceTest">
<!-- 以下都选项可不填 -->
<!-- 服务版本号, 通常在接口不兼容时版本号才需要升级 -->
<jupiter:property version="1.0.0.daily" />
<!-- 序列化/反序列化类型: (proto_stuff, hessian, kryo, java)可选, 默认 proto_stuff -->
<jupiter:property serializerType="proto_stuff" />
<!-- 软负载均衡类型[random, round_robin, ext_spi] -->
<jupiter:property loadBalancerType="round_robin" />
<!-- 派发方式: (round, broadcast)可选, 默认 round (单播) -->
<jupiter:property dispatchType="round" />
<!-- 调用方式: (auto, async)可选, 默认 auto -->
<jupiter:property invokeType="sync" />
<!-- 集群容错策略: (fail_fast, fail_over, fail_safe)可选, 默认 fail_fast (快速失败) -->
<jupiter:property clusterStrategy="fail_over" />
<!-- 在 fail_over 策略下的失败重试次数 -->
<jupiter:property failoverRetries="2" />
<!-- 超时时间设置 -->
<jupiter:property timeoutMillis="3000" />
<jupiter:methodSpecials>
<!-- 方法的单独配置 -->
<jupiter:methodSpecial methodName="sayHello" timeoutMillis="5000" clusterStrategy="fail_fast" />
</jupiter:methodSpecials>
<jupiter:property consumerInterceptors="interceptor1,interceptor2" />
<!-- 可选配置 -->
<!--
SerializerType serializerType // 序列化/反序列化方式
LoadBalancerType loadBalancerType // 软负载均衡类型[random, round_robin, ext_spi]
String extLoadBalancerName; // 扩展软负载均衡唯一标识
long waitForAvailableTimeoutMillis = -1 // 如果大于 0, 表示阻塞等待直到连接可用并且该值为等待时间
InvokeType invokeType // 调用方式 [同步, 异步]
DispatchType dispatchType // 派发方式 [单播, 广播]
long timeoutMillis // 调用超时时间设置
List<MethodSpecialConfig> methodSpecialConfigs; // 指定方法的单独配置, 方法参数类型不做区别对待
ConsumerInterceptor[] consumerInterceptors // 消费者端拦截器
String providerAddresses // provider 地址列表, 逗号分隔(IP直连)
ClusterInvoker.Strategy clusterStrategy; // 集群容错策略
int failoverRetries // fail_over 的重试次数
-->
</jupiter:consumer>
</beans>