You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spring-cloud-tencent/spring-cloud-tencent-examples/polaris-discovery-example
Haotian Zhang b88ff4d187
fix:optimize multi service registration and discovery. (#915)
1 year ago
..
discovery-callee-service fix:optimize multi service registration and discovery. (#915) 1 year ago
discovery-caller-service fix:optimize multi service registration and discovery. (#915) 1 year ago
README-zh.md optimize example 2 years ago
README.md docs:update docs 3 years ago
pom.xml feat:update getPort method of PolarisRegistration. (#803) 2 years ago

README.md

Spring Cloud Polaris Discovery example

Example Introduction

This example shows how to use ```spring-cloud-starter-tencent-polaris-discovery`` in Spring Cloud project for its features.

This example is divided to two microservice, discovery-caller-service and discovery-callee-service. In these two microservices, discovery-caller-service invokes discovery-callee-service.

Instruction

Configuration

The configuration is as the following shows. {ip} and {port} are Polaris backend IP address and port number.

spring:
  application:
    name: ${application.name}
  cloud:
    polaris:
      address: ${ip}:${port}

Launching Example

Launching Polaris Backend Service

Reference to Polaris Getting Started

Launching Application

  • IDEA Launching

Launching spring-cloud-tencent-examples/polaris-discovery-example/discovery-caller-service's DiscoveryCallerService and spring-cloud-tencent-examples/polaris-discovery-example/discovery-callee-service's DiscoveryCalleeService

  • Maven Package Launching

Execute under spring-cloud-tencent-examples/polaris-discovery-example

mvn clean package

Then at discovery-caller-service and discovery-callee-service find the package that generates jar, and run it

java -jar ${app.jar}

Launch application, change ${app.jar} to jar's package name

Verify

Feign Invoke

Execute the following orders to invoke Feign, DiscoveryCalleeService goes bank to the sum of value1+value2

curl -L -X GET 'http://localhost:48080/discovery/service/caller/feign?value1=1&value2=2'

Expected return rate

3

RestTemplate Invoke

Execute the following orders to invoke RestTemplate, DiscoveryCalleeService goes back to string characters

curl -L -X GET 'http://localhost:48080/discovery/service/caller/rest'

Expected return rate

Discovery Service Callee