Cloud Native 8 min read

Zero‑Code Migration: Enable Spring Boot Service Registration and Governance with MSE

This guide shows how to use Alibaba Cloud MSE to non‑intrusively add service registration, discovery, and governance—including full‑chain gray release—to existing Spring Boot applications, with step‑by‑step instructions, demo setup, and practical code snippets.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
Zero‑Code Migration: Enable Spring Boot Service Registration and Governance with MSE

Background

Microservice frameworks such as Apache Dubbo, Nacos and Spring Cloud have driven many enterprises to adopt a microservice architecture, splitting applications into independently deployable services. This enables agile development, continuous delivery and easier scaling of Java applications.

Solution Overview

The solution uses Alibaba Cloud Microservice Engine (MSE) together with its built‑in Nacos registry to provide persistent service discovery and governance for Spring Boot applications without any code changes.

Key Benefits

Persistent service registration that survives pod restarts and does not rely on client‑side memory.

Cross‑platform discovery, supporting both Kubernetes and non‑Kubernetes services.

Non‑intrusive governance for Spring Boot apps, including full‑link gray release, rate limiting, degradation and security.

Demo Environment

A three‑service demo (services A, B and C) is deployed on a Kubernetes cluster. Each service runs a Spring Boot application exposing an HTTP endpoint. The request flow can be observed with a simple curl command: curl http://47.97.117.48/A/spring_boot Expected output (example):

A[10.0.3.238] -> B[10.0.3.227] -> C[10.0.3.230]

Service Registration via MSE Governance

Open the MSE Nacos console and click “Create Service”.

Enter the service name (e.g., sc-A) and group, then select the governance application that will register the service.

Enable health‑check and choose the appropriate protocol (HTTP, TCP, etc.).

Confirm the creation; the service and its instances are now registered in MSE Nacos.

Repeat the process for services B and C, registering them as sc-B and sc-C respectively.

Update the Zuul gateway’s Nacos address configuration so that it registers via the MSE SDK.

To take a service instance offline, open the node detail page in the governance console and click “Service Offline”. The instance is deregistered instantly without restarting the pod.

Service Subscription

Add the environment variable MSE_NACOS_ADDRESS (pointing to the MSE Nacos address) to any Spring Boot application that needs to discover services.

Invoke a registered service directly by its name, for example:

restTemplate.getForObject("http://sc-b:20002/spring_boot", String.class);

By default the service belongs to the DEFAULT_GROUP. The group can be overridden with the query parameter mse_nacos_group (e.g., ?mse_nacos_group=custom).

Validate the subscription in the MSE Nacos console and with an end‑to‑end request: curl http://47.97.117.48/A/spring_boot Expected output shows the request flowing through A → B → C.

Non‑Intrusive Full‑Link Gray Release

Adding the HTTP header x-mse-tag: gray routes traffic to gray‑enabled instances. Example:

curl http://47.97.117.48/A/spring_boot -H "x-mse-tag: gray"

Expected output (example):

Agray[10.0.3.240] -> B[10.0.3.229] -> Cgray[10.0.3.241]

This demonstrates that a Spring Boot application can obtain gray‑release capabilities instantly through MSE governance.

Conclusion

By leveraging MSE’s service governance together with Nacos, Spring Boot applications gain persistent service discovery, zero‑code registration, seamless subscription and full‑link gray release. The approach works without modifying application code or restarting pods, simplifying cloud‑native development and improving developer productivity.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeSpring BootService RegistrationMSEservice governance
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

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.