A day of paddling
I forgot my notebook when I came back. I need a computer to build an environment. It’s too late to paddle in the water. Use Gitee to check the connection of soul-example, SOFA and Tars. It is found that SOFA and Tars need to use SpringBoot boot to start the connection. I don’t think so. Look at the code later.
Micro service is the back-end architecture of the current business, big factories are also open source part of their own framework, began to pursue the whole family bucket. Combined with DevOps, container and continuous delivery of business, the prototype of cloud Native concept is formed. Several keywords are recorded here for further study of CNCF and ServiceMech.
Other:
Start looking at the source code this week.
Some unhappy things happened today and I began to regret my decision.
I am very happy that PR was merged at the weekend. I hope Soul will learn to stick to it and write to the 28th day.
2. Agent SpringCloud
Don’t want to paddle, so fill in the proxy SpringCloud today.
1. Proxy HTTP and SpringCloud differences
SpringCloud, also known as Spring’s bucket of microservices support, joins the registry Eureka and the client load balancer Ribbon. In fact, where the gateway is used, there is a high probability that there will be a registry, and the gateway cannot manage the registration of services. It feels that the responsibilities are not clear enough. The Ribbon selects the service instance based on the service name. The Ribbon selects the service instance based on the service name.
2. Preparation
Start Eureka. I created a Eureka project using IDEA. Please post the POM file generated by the official
<? The XML version = "1.0" encoding = "utf-8"? > < project XMLNS = "http://maven.apache.org/POM/4.0.0" XMLNS: xsi = "http://www.w3.org/2001/XMLSchema-instance" Xsi: schemaLocation = "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" > < modelVersion > 4.0.0 < / modelVersion > < the parent > < groupId > org. Springframework. Boot < / groupId > The < artifactId > spring - the boot - starter - parent < / artifactId > < version > 2.4.2 < / version > < relativePath / > <! -- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name> Eureka-server-demo </name> <description>Demo project for Spring Boot < / description > < properties > < Java version > 1.8 < / Java version > < spring - cloud. Version > 2020.0.0 < / spring - cloud. Version > </properties> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <repositories> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> </repository> </repositories> </project>Copy the code
Then I copied a set of application.yml configuration online
### Service port number
server:
port: 8761
#Eureka basic information configurationAddress hostname: 127.0.0.1 Client: serviceUrl: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ ### because I am a register-with-eureka, I do not need to register myself: ### Enable the self-preservation mechanism to enable the unusable service to be removed when testing. false eviction-interval-timer-in-ms: 2000Copy the code
Start classes with Eureka Server start annotations.
3. Agent SpringCloud
Four steps:
- Start the Eureka
- Open the springCloud plug-in in plug-in management in Soul background administration
- Modify the configuration and restart
soul-boostrap
- Launch two SpringCloud projects
1) restartsoul-boostrap
, encountered pit, but also three places to configure:
-
Because Eureka and the Ribbon are used, we need to add the dependencies of Eureka Client, the Ribbon, and SpringCloud to soul-bootstrap.
-
I used the master branch code directly, soul-bootstrap default springCould plugin dependencies are commented out, to open.
-
To enable the Eureka configuration file, ensure that the port is the same as the starting Rureka port.
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
instance:
prefer-ip-address: true
Copy the code
Why say pit, because 2, 3 two steps do not do, start also do not report error, it is not important. The important thing is that when the client requests the server, it returns an error code, but the server does not type the error log, can you add a pr ^_^!!
2) Start two SpringCloud services
Continue with the springCloud example startup in soul-example, modify the port and parallel startup configuration, and start both.
You can see that one Soul gateway service and two HTTP services are registered on Eureka with ports 8884 and 8885.
A curl http://localhost:9195/springcloud/order/findById\? operation Id \=3 You can see that ports 8884 and 8885 in the gateway log are accessed.