sidecar异构微服务

0、理解

通过sidecar将异构平台的微服务注册到Eureka;让其和SpringCloud的生态空间连在一起;

1、使用

pom.xml`

<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-netflix-sidecar</artifactId>
</dependency>

application.yml

spring:
  application:
    name: microservice-sidecar
server:
  port: 8070
eureka: 
  client: 
    service-url:
      defaultZone: http://localhost:8761/eureka
  instance:
    prefer-ip-address: true
sidecar:
  port: 8060
  health-uri: http://localhost:8060/health.json
   

启动类SidecarApplication.java

@SpringBootApplication
//注册Sidecar;@EnableSidecar是一个组合注解
@EnableSidecar
public class SidecarApplication {
	public static void main(String[] args) {
		System.out.println("Hello Zuul!");
		SpringApplication.run(SidecarApplication.class, args);
	}
}

注意

  • 1、
    当异构微服务和eureka不运行在同一个hostname上时,我们需要配置
    ${eureka.instance.hostName}
  • 2、每一个异构微服务节点就需要一个sidecar,当需要异构的微服务很多时,就很麻烦了;且sidecar本身对业务没什么作用,仅仅做一个‘汇总’。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MobiusStrip

请我喝杯奶茶吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值