Dubbo Service Isolation and Local Development Configuration Solutions
This article explains how to configure Dubbo for local service calls and test‑environment isolation by using @Reference URL specifications, a user‑home properties file, and Nacos namespace isolation, providing practical steps for backend developers to avoid cross‑instance interference and streamline branch testing.
Background
A colleague asked about Dubbo usage: they want to call their own services locally during development, e.g., modify service A, start service B, and have A call B without hitting other instances.
Requirement 1
When developing locally they need to call their own service directly, but using the same registry causes calls to other instances. They tried to set @Reference(url="dubbo://localhost:20880") but it didn't work.
@Reference(url="dubbo://localhost:20880")Requirement 2
In their test environment each service has a single instance and no Docker. Multiple branches are merged and deployed together, causing conflicts. They also need to isolate branches for regression testing, but cannot afford a separate instance per branch.
Solution
Solution for Requirement 1
@Reference
Specifying the URL in @Reference is possible; the address must include the interface and version.
@Reference(url="dubbo://localhost:20880/com.xxx.xxx:1.0")Local configuration file
Instead of hard‑coding the URL, create a dubbo-resolve.properties file in the user home directory and map the interface to the desired address.
com.xxx.xxx=dubbo://localhost:20880/com.xxx.xxx:1.0.0Solution for Requirement 2
Since a full deployment overhaul is not feasible, add an isolated test environment or use namespace isolation in Nacos.
Registry isolation
Register each team's services in a separate namespace; Nacos supports this via the -Ddubbo.registry.address parameter.
-Ddubbo.registry.address=nacos://api.nacos.beta.xxx.com:8848?namespace=xxxLocal configuration file
The same properties‑file approach can be used on dedicated machines, but any new interface requires updating the file.
Dubbo routing or load balancing
Control routing or load‑balancing to select the desired provider; see the official Dubbo documentation for router and load‑balance implementations.
Official docs: http://dubbo.apache.org/zh-cn/docs/dev/impls/router.html, http://dubbo.apache.org/zh-cn/docs/dev/impls/load-balance.html
Conclusion
For Requirement 1, using a local properties file is the simplest, non‑code‑changing solution.
For Requirement 2, registry isolation via Nacos namespaces provides a clean separation, eliminating the need for additional routing tricks.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Full-Stack Internet Architecture
Introducing full-stack Internet architecture technologies centered on Java
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
