22.2. 使用静态故障切换启用 HA


概述

要使用静态故障转移启用 HA,您必须执行以下操作:

在您的服务 WSDL 文件中编码副本详情

您必须在服务 WSDL 文件中对集群中的副本进行编码。例 22.1 “使用静态故障转移启用 HA:WSDL 文件” 显示 WSDL 文件提取,以定义三个副本的服务集群。

例 22.1. 使用静态故障转移启用 HA:WSDL 文件

<wsdl:service name="ClusteredService">
    <wsdl:port binding="tns:Greeter_SOAPBinding" name="Replica1">
        <soap:address location="http://localhost:9001/SoapContext/Replica1"/>
    </wsdl:port>

    <wsdl:port binding="tns:Greeter_SOAPBinding" name="Replica2">
        <soap:address location="http://localhost:9002/SoapContext/Replica2"/>
    </wsdl:port>

    <wsdl:port binding="tns:Greeter_SOAPBinding" name="Replica3">
        <soap:address location="http://localhost:9003/SoapContext/Replica3"/>
    </wsdl:port>

</wsdl:service>

例 22.1 “使用静态故障转移启用 HA:WSDL 文件” 中显示的 WSDL 提取可以解释如下:

定义服务 ClusterService,它在三个端口上公开:

  1. Replica1
  2. Replica2
  3. Replica3

定义 Replica1,以通过端口 9001 上的 HTTP 端点公开 ClusterService 作为 SOAP。

定义 Replica2,以在端口 9002 上通过 HTTP 端点公开 ClusterService 作为 SOAP。

定义 Replica3,以在端口 9003 上通过 HTTP 端点公开 ClusterService 作为 SOAP。

在您的客户端配置中添加集群功能

在客户端配置文件中,添加集群功能,如 例 22.2 “使用静态故障转移启用 HA:客户端配置” 所示。

例 22.2. 使用静态故障转移启用 HA:客户端配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns:clustering="http://cxf.apache.org/clustering"
         xsi:schemaLocation="http://cxf.apache.org/jaxws
         http://cxf.apache.org/schemas/jaxws.xsd
         http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd">

    <jaxws:client name="{http://apache.org/hello_world_soap_http}Replica1"
                  createdFromAPI="true">
        <jaxws:features>
            <clustering:failover/>
        </jaxws:features>
    </jaxws:client>

    <jaxws:client name="{http://apache.org/hello_world_soap_http}Replica2"
                  createdFromAPI="true">
        <jaxws:features>
            <clustering:failover/>
        </jaxws:features>
    </jaxws:client>

    <jaxws:client name="{http://apache.org/hello_world_soap_http}Replica3"
                  createdFromAPI="true">
        <jaxws:features>
            <clustering:failover/>
        </jaxws:features>
    </jaxws:client>

</beans>
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.