Questo contenuto non è disponibile nella lingua selezionata.
Chapter 22. Enabling High Availability
Abstract
This chapter explains how to enable and configure high availability in the Apache CXF runtime.
22.1. Introduction to High Availability Copia collegamentoCollegamento copiato negli appunti!
Overview Copia collegamentoCollegamento copiato negli appunti!
Scalable and reliable applications require high availability to avoid any single point of failure in a distributed system. You can protect your system from single points of failure using replicated services.
A replicated service is comprised of multiple instances, or replicas, of the same service. Together these act as a single logical service. Clients invoke requests on the replicated service, and Apache CXF delivers the requests to one of the member replicas. The routing to a replica is transparent to the client.
HA with static failover Copia collegamentoCollegamento copiato negli appunti!
Apache CXF supports high availability (HA) with static failover in which replica details are encoded in the service WSDL file. The WSDL file contains multiple ports, and can contain multiple hosts, for the same service. The number of replicas in the cluster remains static as long as the WSDL file remains unchanged. Changing the cluster size involves editing the WSDL file.
22.2. Enabling HA with Static Failover Copia collegamentoCollegamento copiato negli appunti!
Overview Copia collegamentoCollegamento copiato negli appunti!
To enable HA with static failover, you must do the following:
Encode replica details in your service WSDL file Copia collegamentoCollegamento copiato negli appunti!
You must encode the details of the replicas in your cluster in your service WSDL file. Example 22.1, “Enabling HA with Static Failover: WSDL File” shows a WSDL file extract that defines a service cluster of three replicas.
Example 22.1. Enabling HA with Static Failover: WSDL File
The WSDL extract shown in Example 22.1, “Enabling HA with Static Failover: WSDL File” can be explained as follows:
Defines a service, ClusterService
, which is exposed on three ports:
-
Replica1
-
Replica2
-
Replica3
Defines Replica1
to expose the ClusterService
as a SOAP over HTTP endpoint on port 9001
.
Defines Replica2
to expose the ClusterService
as a SOAP over HTTP endpoint on port 9002
.
Defines Replica3
to expose the ClusterService
as a SOAP over HTTP endpoint on port 9003
.
Add the clustering feature to your client configuration Copia collegamentoCollegamento copiato negli appunti!
In your client configuration file, add the clustering feature as shown in Example 22.2, “Enabling HA with Static Failover: Client Configuration”.
Example 22.2. Enabling HA with Static Failover: Client Configuration
22.3. Configuring HA with Static Failover Copia collegamentoCollegamento copiato negli appunti!
Overview Copia collegamentoCollegamento copiato negli appunti!
By default, HA with static failover uses a sequential strategy when selecting a replica service if the original service with which a client is communicating becomes unavailable, or fails. The sequential strategy selects a replica service in the same sequential order every time it is used. Selection is determined by Apache CXF’s internal service model and results in a deterministic failover pattern.
Configuring a random strategy Copia collegamentoCollegamento copiato negli appunti!
You can configure HA with static failover to use a random strategy instead of the sequential strategy when selecting a replica. The random strategy selects a random replica service each time a service becomes unavailable, or fails. The choice of failover target from the surviving members in a cluster is entirely random.
To configure the random strategy, add the configuration shown in Example 22.3, “Configuring a Random Strategy for Static Failover” to your client configuration file.
Example 22.3. Configuring a Random Strategy for Static Failover
The configuration shown in Example 22.3, “Configuring a Random Strategy for Static Failover” can be explained as follows:
Defines a Random
bean and implementation class that implements the random strategy.
Specifies that the random strategy is used when selecting a replica.