Eureka整合sidecar异构调用
本次使用nodejs脚本生成的异构程序测试:
node-server.js
var http = require('http');
var url = require('url');
var path = require('path');
//创建server
var server = http.createServer(function(req, res){
//获得请求路径
var pathname = url.parse(req.url).pathname;
res.writeHead(200, {'Content-Type':'application/json; charset=utf-8'});
if(pathname === '/'){
res.end(JSON.stringify({ "index":"欢迎" }));
}else if(pathname === '/health.json'){
res.end(JSON.stringify({ "status":"UP" }));
}else{
res.end("404");
}
});
//创建监听,并打印日志
server.listen(8060, function(){
console.log('listening on localhost:8060');
});
生成js文件保存执行cmd node+路径
测试 : localhost:8060 是否正常访问

1.首先修改Zuul网关的配置:
server:
port: 8050
spring:
application:
name: client-Zuul
eureka:
client:
serviceUrl:
defaultZone: http://user:password123@localhost:8761/eureka
zuul:
ignoredServices: '*'
routes:
app-provider-user: #名称随意,唯一就好
path: /user/**
serviceId: provider-user
app-sidecar: #通过sidecar调用nodejs的服务
path: /sidecar/**
serviceId: sidecar
2.SideCarRunApp.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.sidecar.EnableSidecar; @SpringBootApplication
@EnableSidecar
public class SideCarRunApp { public static void main(String[] args) {
SpringApplication.run(SideCarRunApp.class, args);
} }
application.yml
server:
port: 8070
spring:
application:
name: sidecar
eureka:
client:
serviceUrl:
defaultZone: http://user:password123@localhost:8761/eureka
sidecar:
port: 8060
health-uri: http://localhost:8060/health.json
pom.xml
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eureka.sidecar</groupId>
<artifactId>eureka-sidecar</artifactId>
<version>0.0.1-SNAPSHOT</version> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-sidecar</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

Eureka整合sidecar异构调用的更多相关文章
- 关于spring cloud eureka整合ribbon实现客户端的负载均衡
1. 实现eureka整合ribbon非常简单, 1.1.首先引入所需maven依赖 <dependency> <groupId>org.springframework.boo ...
- 【Eureka】服务发现调用
[Eureka]服务发现调用 转载:https://www.cnblogs.com/yangchongxing/p/10779832.html 1.使用 Netfix Feign 客户端调用服务 首先 ...
- 【一起学源码-微服务】Ribbon 源码三:Ribbon与Eureka整合原理分析
前言 前情回顾 上一篇讲了Ribbon的初始化过程,从LoadBalancerAutoConfiguration 到RibbonAutoConfiguration 再到RibbonClientConf ...
- spring整合mongo及调用
spring整合mongo(maven工程下): 1.web.xml文件中配置需要加载的配置文件: <listener> <listener-class>org.springf ...
- 【Eureka篇三】Eureka如何管理服务调用(6)
在Eureka Client启动时,将自身的服务的信息发送到Eureka Server.然后进行2调用当前服务器节点中的其他服务信息,保存到Eureka Client中.当服务间相互调用其它服务时,在 ...
- 【Spring Boot学习之六】Spring Boot整合定时任务&异步调用
环境 eclipse 4.7 jdk 1.8 Spring Boot 1.5.2一.定时任务1.启动类添加注解@EnableScheduling 用于开启定时任务 package com.wjy; i ...
- Spring Cloud Eureka整合使用和配置
遵循SpringBoot三板斧 服务端 第一步加依赖 <dependency> <groupId>org.springframework.cloud</groupId&g ...
- SpringCloud Sidecar 整合.Net WebApi
在整合.Net的过程中遇到不少问题,一般网上的例子只是调用一个简单的NodeJS示例,并未有详细的介绍及采坑过程. 首先,我的项目结构是:Vue前端 + SpringCloud后端 + .Net的We ...
- Spring Cloud微服务系列文,Hystrix与Eureka的整合
和Ribbon等组件一样,在项目中,Hystrix一般不会单独出现,而是会和Eureka等组件配套出现.在Hystrix和Eureka整合后的框架里,一般会用到Hystrix的断路器以及合并请求等特性 ...
随机推荐
- shiro-重写标签功能----shiro:hasPermission 标签重写
public abstract class ShiroAuthorizingRealm extends AuthorizingRealm{ private static final String OR ...
- (最新 9000 字 )Spring Boot 配置特性解析
爱生活,爱编码,微信搜一搜[架构技术专栏]关注这个喜欢分享的地方.本文 架构技术专栏 已收录,有各种JVM.多线程.源码视频.资料以及技术文章等你来拿 一.概述 目前Spring Boot版本: 2. ...
- 本地保存cookie
原文https://blog.csdn.net/qq_29663071/article/details/73826642 https://www.cnblogs.com/webcome/p/54709 ...
- jpa基本常识
1.hibernate更新表结构配置 jpa hibernate框架配置 spring.jpa.properties.hibernate.hbm2ddl.auto = create-drop 其意思是 ...
- 小伙伴想学Jenkins自动构建发布项目,我:安排上了!!
写在前面 趁着十一长假,很多小伙伴都在悄悄学习,有些是为了能够顺利通过面试,进入大厂升职加薪.有些则是为了进一步巩固和提高自己的专业技能,希望有朝一日能过成为互联网架构师乃至技术专家.这不,就有小伙伴 ...
- MySQL 修改表中的字段,使其自增
例如,我想使字段 id 自增. 1.查看表定义 mysql> DESC user; +----------+-------------+------+-----+---------+------ ...
- 《穷查理年鉴》诚实 & 希望 & 勇气 & 失败 & 改变(关于美好)
诚实 013.自欺是最常见的欺骗. 038.毫无顾忌进行欺骗的人是无所畏惧的. 043.问心无愧者永无所惧. 068.诚实的人从欺诈人手中得到的买卖,我们从争论中得到真理. 134.没有欺骗就没有信任 ...
- STM32之旅1——LED
STM32之旅1--LED 学习了51单片机后,就要接触到更高级一点的单片机了,比如STM32,ST也有很多款单片机,现在用比较基础的学习--STM32F103RCT6. LED驱动 hal库的使用比 ...
- Windows Server 2003 蓝屏 -- 系统故障:停止错误
Windows Server 2003 EE 出现蓝屏: 0X0000004D (0X000f27D9, 0X000F27D9, 0X0000000C, 0X00000000) 蓝屏拍照: 重启机器 ...
- RHSA-2017:3075-重要: wget 安全更新(代码执行)
[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) 修复命令: 使用root账号登陆She ...