Cloud Native 10 min read

Fast-Track Spring Boot Service Mesh: Integrating PolarisMesh with Feign

This article explains how PolarisMesh, Tencent's open‑source service discovery and governance platform, solves service address management and fault tolerance challenges in a Spring Boot microservice ecosystem, and provides step‑by‑step instructions—including Maven dependency, provider and consumer configuration, and sample code—to quickly integrate PolarisMesh via Feign.

Tencent Cloud Middleware
Tencent Cloud Middleware
Tencent Cloud Middleware
Fast-Track Spring Boot Service Mesh: Integrating PolarisMesh with Feign

Background

PolarisMesh is Tencent's open‑source service discovery and governance center, supporting millions of services and massive traffic. It provides service addressing, traffic scheduling, fault tolerance, and access control. It can be used both on Kubernetes and virtual‑machine environments and is compatible with gRPC, Spring Cloud, and other ecosystems.

Problem Statement

In a product middle‑platform, services originally called each other via RESTful VIP direct connections. As the platform grew, the number of dependent services increased, making service address management, fault tolerance, and iterative upgrades difficult. A unified service governance solution was required.

Requirements

Ease of use : Minimal changes to existing code, e.g., keep Feign‑style RPC.

Reduce duplicate work : Avoid hand‑written load‑balancing, circuit‑breaker, and rate‑limit code.

Visual configuration : Dynamic flow control and routing rules.

Multi‑language support : Ability to integrate services written in Java, Python, Go, etc.

Technology Choice

After evaluating several service‑governance frameworks, PolarisMesh (https://github.com/polarismesh/polaris) best matched the needs.

PolarisMesh Overview

Provider Functions

Service discovery: retrieve registration info and dynamic routing/fault‑tolerance/load‑balancing/rate‑limit rules.

Dynamic routing: select service instances based on routing rules.

Load balancing: choose an instance according to balancing strategy.

Fault tolerance: circuit‑break based on rules and call results.

Consumer Functions

Service registration: providers register their address at startup.

Heartbeat reporting: health‑check reporting.

Access limiting: enforce local or distributed rate limits.

Server Functions

Registry: store registration data and policies.

Control plane: remote configuration and rule distribution.

Monitoring: collect metrics for visualization and alerts.

Data plane: SDK or sidecar implements routing, load balancing, and fault tolerance.

Quick Integration Steps for Spring Boot

Add the starter dependency

<dependency>
    <groupId>com.tencent.nameservice</groupId>
    <artifactId>spring-boot-polaris-starter</artifactId>
    <version>${project.version}</version>
</dependency>

Provider side Annotate the main class with @EnablePolarisProvider and configure registration in application.properties :

# Environment configured in Polaris console
spring.polaris.provider.namespace=Development
# Service name created in Polaris console
spring.polaris.provider.service=polaris-book-service
# Service token
spring.polaris.provider.token=732454617cb94125930d1352237150a6

Consumer side Annotate the main class with @PolarisConsumerScan("com.tencent.nameservice.sdk.consumer.remote") . Define a remote interface:

@PolarisConsumer(id = "book")
public interface BookClient {
    @RequestLine("GET /book/{id}")
    R<Book> getBook(@Param("id") String id);
}

Configure the consumer in application.properties :

spring.polaris.consumer.book.namespace=Development
spring.polaris.consumer.book.service=polaris-book-service

Use the client

@Component
public class DemoService {
    @Resource
    private BookClient bookClient;

    public R<Book> getBook() {
        return bookClient.getBook("bookId");
    }
}

Conclusion

PolarisMesh provides a rich SDK that lowers migration effort, especially for Spring Boot + Feign users, enabling a near‑seamless switch. After integration, address lists and custom rate‑limit code disappear, and the dashboard offers intuitive visual control for gray releases, weight adjustments, and routing.

For more details, see the official README: https://github.com/polarismesh/polaris/blob/main/README-zh.md

Relevant repositories: https://github.com/polarismesh/polaris (server), https://github.com/polarismesh/polaris-java (client), https://github.com/polarismesh/polaris-go, etc.

cloud-nativemicroservicesSpring BootfeignPolarisMesh
Tencent Cloud Middleware
Written by

Tencent Cloud Middleware

Official account of Tencent Cloud Middleware. Focuses on microservices, messaging middleware and other cloud‑native technology trends, publishing product updates, case studies, and technical insights. Regularly hosts tech salons to share effective solutions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.