You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project demonstrates how to use `Nacos + Spring Cloud Alibaba Sidecar` to access heterogeneous language microservices.
5
+
This project demonstrates how to use Nacos + Spring Cloud Alibaba Sidecar to accomplish heterogeneous microservice access.
6
6
7
-
[Spring Cloud Alibaba Sidecar](https://spring-cloud-alibaba-group.github.io/github-pages/hoxton/zh-cn/index.html#_spring_cloud_alibaba_sidecar)is a framework for fast and seamless integration of Spring Cloud with heterogeneous language microservices.
7
+
[Spring Cloud Alibaba Sidecar](https://sca.aliyun.com/zh-cn/docs/2022.0.0.0/user-guide/sidecar/overview)is a framework for quickly and seamlessly integrating Spring Cloud applications with heterogeneous microservices. services.
8
8
9
+
## Preparation
9
10
11
+
### Download and start Nacos
10
12
11
-
## Preparation
13
+
**Before you can access Sidecar, you need to start Nacos Server.**
12
14
13
-
###Download and Startup Nacos
15
+
1. Download [Nacos Server](https://github.com/alibaba/nacos/releases/download/2.1.0/nacos-server-2.1.0.zip)and unzip it. 2.
14
16
15
-
**You should startup Nacos Server before using Sidecar**
17
+
2. Start Nacos Server
16
18
17
-
1. Download [Nacos](https://archive.apache.org/dist/rocketmq/4.3.2/rocketmq-all-4.3.2-bin-release.zip) and unzip it.
19
+
After downloading and unpacking, you need to go to the bin directory to start the nacos server, make sure you don't double-click to start it, double-clicking will start it as a cluster by default. Here, we will start it as a standalone server:
18
20
19
-
2. Startup Name Server
21
+
```bash
22
+
startup.cmd -m standalone
23
+
```
20
24
21
-
```bash
22
-
startup.cmd -m standalone
23
-
```
25
+
3. Log in to Nacos
26
+
27
+
Type localhost:8848/nacos in your browser to see the Nacos console, and enter your username and password to log in to Nacos (username and password both are `nacos`);
24
28
25
-
3. Sign in Nacos
26
-
27
-
Open you browser then input `localhost:8848/nacos` ,you can see the Nacos dashboard ui .
28
-
The default username and password are `nacos`
29
+
## Simple Example
29
30
31
+
In this article, we use Nacos as a registry as an example, and Sidecar to access a non-Java language service.
30
32
31
-
## Simple example
32
-
In this paper, Sidecar accesses a non-Java language service using Nacos as a registry as an example.
33
+
> By default, we use the golang language service as an example, and we can start the `node` heterogeneous service in `application.yml`.
33
34
35
+
### Step1: Introducing dependencies
34
36
35
-
### Step1: Declare dependency
36
-
Add dependency spring-cloud-starter-alibaba-sidecar to the `pom.xml` file in your Sidecar project.
37
+
Modify the `pom.xml` file to introduce Spring Cloud Alibaba Sidecar Starter.
37
38
38
39
```xml
39
40
<dependency>
@@ -52,68 +53,80 @@ Add dependency spring-cloud-starter-alibaba-sidecar to the `pom.xml` file in you
52
53
</dependency>
53
54
```
54
55
55
-
### Step2: Configure sidecar
56
-
Then add necessary configurations to file `/src/main/resources/application.yml`.
56
+
### Step2: Configure Sidecar related information
57
+
58
+
Then specify the following configuration in the project's `application.yml` configuration file:
Note: `localhost:8060` here, is my local machine started a nginx proxy for this `health.json` request. In actual use it can be any REST service, just need to return the correct JSON format health detection data.
85
-
```json
86
96
97
+
Note: localhost:8050 is the address of the heterogeneous service. In practice it can be any REST service, it just needs to return the correct JSON formatted health test data.
98
+
99
+
```json
87
100
{
88
-
"status": "DOWN"
101
+
"status": "UP"
89
102
}
90
103
```
91
104
92
-
### Step3: Start Application
93
-
After that, start the `Sidecar` service and the local heterogeneous service respectively.
105
+
### Step3: Starting the application
106
+
107
+
After that, start the Sidecar service and local heterogeneous service respectively.
94
108
95
-
Start in IDE: Find main class `com.alibaba.cloud.sidecar.DemoApplication`, and execute the main method.
109
+
IDE direct start: find the main class `com.alibaba.cloud.sidecar.DemoApplication` and execute the main method to start the application.
110
+
111
+
Note: In this article, we take the `spring-cloud-alibaba-sidecar-nacos-example` project as an example, so we start the `DemoApplication` startup class under it.
96
112
97
-
Note: This article takes the `spring-cloud-alibaba-sidecar-nacos-example` project as an example, so it starts the `DemoApplication` startup class under it.
After completing the above 4 steps, we find that the corresponding service `sidecar-service` has been successfully registered to the registry. At this point, this service has been successfully integrated into Spring Cloud microservices. For Spring Cloud microservices, accessing it is no different from accessing other Java microservices.
122
+
This is the beauty of Spring Cloud Alibaba Sidecar. Next, we will continue to demonstrate how to access this service.
105
123
106
-
### Step4: Accessing services
107
-
After completing the above 4 steps, we find that the corresponding service `node-service` has been successfully registered to the registry. At this point, the service has been successfully integrated into the Spring Cloud microservice. For Spring Cloud microservices, accessing it is no different than accessing any other Java microservice.
108
-
This is where the beauty of Spring Cloud Alibaba Sidecar comes in. Next, we will continue to demonstrate how to access this service.
If you have any ideas or suggestions for `Spring Cloud Alibaba Sidecar`, please don't hesitate to tell us by submitting github issues.
119
-
132
+
If you have any suggestions or ideas about spring cloud starter alibaba sidecar, please feel free to submit them to us in an Issue or through other community channels.
0 commit comments