tencent cloud

Service Registry and Governance

Service fusing

PDF
Focus Mode
Font Size
Last updated: 2026-05-07 18:12:22

Circuit Breaking Scenario

Spring Cloud Tencent CircuitBreaker provides a standard circuit breaking implementation by leveraging Polaris's circuit breaking capabilities. It offers three circuit breaking levels: service-level, API-level, and instance-level, which can be combined as needed to achieve the desired circuit breaking effect.
This document describes how to develop a Java application locally, access Polaris (North Star) via Spring Cloud, and use the service circuit breaking feature.

Prerequisite

Before starting development, please ensure you have downloaded and installed Java and Maven.

Operation Steps

Step 1: Importing Dependencies

1.1 Add the spring cloud tencent Dependency

Modify the pom.xml in the application's root directory to add dependencyManagement:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-dependencies</artifactId>
<version>${version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Note:
Please select the appropriate Spring Cloud Tencent version based on the versions of Spring Boot and Spring Framework in the project.

1.2 Introduce spring cloud tencent starter

Note:
Since circuit breaking depends on service discovery, both the caller and the callee must introduce the dependency for service registration and discovery.
Method 1: Introduce all sct starters via spring-cloud-starter-tencent-all.
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-all</artifactId>
</dependency>
Method 2: Only introduce spring-cloud-starter-tencent-polaris-circuitbreaker.
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
</dependency>

Step 2: Add the Relevant Configuration Files and Configure the Circuit Breaking Method

Spring Cloud Tencent supports circuit breaking for three components: Feign, RestTemplate, and Spring Cloud Gateway. It automatically fetches the circuit breaking rules configured for the callee service on Polaris to perform circuit breaking.

Step 3: Verifying Configurations

Start the application and set service-level circuit breaking rules for the callee service in the Polaris console. See the Service Circuit Breaking and Active Probing documentation. The related page is shown below:

To verify the circuit breaking capability, start at least two instances on the callee side: one returning success and one returning failure.
When the caller initiates a service call to the callee, the first few requests may be sent to the problematic service instance. When the number of errors reaches the circuit breaking threshold configured in the Polaris console, circuit breaking is triggered. The caller then stops sending requests and directly returns the circuit breaking fallback method.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback