All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pc.jupiter-example.1.2.21.source-code.spring-consumer.xml Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
<?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] -->
        <jupiter:property loadBalancerType="round_robin" />
        <!-- 派发方式: (round, broadcast)可选, 默认round(单播) -->
        <jupiter:property dispatchType="round" />
        <!-- 调用方式: (sync, async)可选, 默认sync(同步调用) -->
        <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]
            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>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy