spring-cloud

Adding Headers to Zuul when re-directing

ぃ、小莉子 提交于 2020-01-11 08:48:14
问题 I am trying to use Zuul to redirect calls to a downstream system somewhere else. In the re-direct, I need to add in a Header with necessary data for the api receiving the redirection to process. I can't seem to get the downstream system to detect this data. Attached is my code. I am using Zuul from Edgware.SR3, Spring Boot 1.5.12 Zuul Filter @Component public class RouteFilter extends ZuulFilter{ @Override public Object run() { //Testing to add header context.getRequest().getParameterMap()

SpringCloud之Ribbon负载均衡及Feign消费者调用服务

≯℡__Kan透↙ 提交于 2020-01-10 20:21:21
springcloud 1、微服务调用Ribbon 简介 初步应用 2、Ribbon负载均衡 3、Feign简介及应用 简介 应用 1、微服务调用Ribbon 简介 前面讲了eureka服务注册与发现,但是结合eureka集群的服务调用没讲。 这里的话 就要用到Ribbon,结合eureka,来实现服务的调用; Ribbon是Netflix发布的负载均衡器,它有助于控制HTTP和TCP的客户端的行为。为Ribbon配置服务提供者地址后,Ribbon就可基于某种负载均衡算法,自动地帮助服务消费者去请求。Ribbon默认为我们提供了很多负载均衡算法,例如轮询、随机等。当然,我们也可为Ribbon实现自定义的负载均衡算法。 在Spring Cloud中,当Ribbon与Eureka配合使用时,Ribbon可自动从Eureka Server获取服务提供者地址列表,并基于负载均衡算法,请求其中一个服务提供者实例。展示了Ribbon与Eureka配合使用时的架构。 初步应用 Ribbon是客户端负载均衡,所以肯定集成再消费端,也就是consumer端 我们修改microservice-student-consumer-80 首先,引入依赖,pom.xml 加入 ribbon相关依赖 <!--ribbon相关依赖--> < dependency > < groupId > org

Unable to connect to Command Metric Stream for Hystrix Dashboard with Spring Cloud

亡梦爱人 提交于 2020-01-10 19:52:25
问题 I have microservices project with Spring Cloud, the snippet from parent: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.7.RELEASE</version> </parent> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Dalston.SR3</version> <type>pom</type> <scope>import</scope> </dependency> All services are running under Eureka server:

spring-cloud-starter-eureka-server 和 spring-cloud-starter-netflix-eureka-server的区别

爱⌒轻易说出口 提交于 2020-01-10 10:08:39
在学习分布式配置中心,查资料时看到maven引入部分使用了spring-cloud-starter-eureka-server,部分使用了spring-cloud-starter-netflix-eureka-server。特意去查了下 springcloud更新换代比较快,可能1.5可以使用,到了2.0就不用了。所以做项目或者练习时要看清自己使用的版本。1.5版本使用spring-cloud-starter-eureka-server还是没问题的。2.0以上建议使用 spring-cloud-starter-netflix-eureka-server。springcloud坑比较多,多做笔记多联系。 分类: Springcloud 标签: springcloud 好文要顶 关注我 收藏该文 一棵写代码的柳树 关注 - 1 粉丝 - 2 +加关注 0 0 « 上一篇: 关于git远程被覆盖的问题 » 下一篇: 分布式配置中心config-client配置报错:java.lang.IllegalStateException: duplicate key: spring 在学习分布式配置中心,查资料时看到maven引入部分使用了spring-cloud-starter-eureka-server,部分使用了spring-cloud-starter-netflix-eureka

HATEOAS paths are invalid when using an API Gateway in a Spring Boot app

微笑、不失礼 提交于 2020-01-09 20:33:42
问题 I have two spring boot applications where one of them is acting as an API Gateway (as discussed here Spring Example). The other which is wired into the first one is exposing a profile service using spring-data-rest (spring-data-neo4j-rest). The first application is starting on port 8080 and is using zuul to route requests to the second as follows: zuul: routes: profiles: path: /profiles/** url: http://localhost:8083/profiles/ This all works fine and requests to http://localhost:8080/profiles

微服务架专题四:Spring-Cloud组件:ribbon 及自定义负载均衡策略

帅比萌擦擦* 提交于 2020-01-08 15:15:00
一、ribbon是什么? Spring Cloud Ribbon是基于Netflix Ribbon实现的一套客户端 负载均衡的工具。 简单的说,Ribbon是Netflix发布的开源项目,主要功能是提供客户端的软件负载均衡算法,将Netflix的中间层服务连接在一起。Ribbon客户端组件提供一系列完善的配置项如连接超时,重试等。简单的说,就是在配置文件中列出Load Balancer(简称LB)后面所有的机器,Ribbon会自动的帮助你基于某种规则(如简单轮询,随机连接等)去连接这些机器。我们也很容易使用Ribbon实现自定义的负载均衡算法。 二、客户端负载均衡?? 服务端负载均衡?? 我们用一张图来描述一下这两者的区别 这篇文章里面不会去解释nginx,如果不知道是什么的话,可以先忽略, 先看看这张图 服务端的负载均衡是一个url先经过一个代理服务器(这里是nginx),然后通过这个代理服务器通过算法(轮询,随机,权重等等…)反向代理你的服务,来完成负载均衡 而客户端的负载均衡则是一个请求在客户端的时候已经声明了要调用哪个服务,然后通过具体的负载均衡算法来完成负载均衡。 三、如何使用: 首先,我们还是要引入依赖,但是,eureka已经把ribbon集成到他的依赖里面去了,所以这里不需要再引用 ribbon的依赖,如图: 依赖: < dependency > < groupId

Unable to access Jhipster generated micro services on jhipster-registry in Aws Elastic Beanstalk

倾然丶 夕夏残阳落幕 提交于 2020-01-07 05:34:11
问题 I deployed my gateway, microservices and jhipster-registry applications on Aws Elastic Beanstalk. Applications are registered successfully on the registry. I am able to access the UI as well however when I try to access the api's it throws the below error: I can see the microservices app in the gateway as well. When I try to access the applications by clicking on the links inside registry I get server DNS address could not be found . Any idea what I am doing wrong here? Everything works fine

Changing Spring Boot Properties Programmatically

和自甴很熟 提交于 2020-01-07 03:08:23
问题 I'm trying to write tests for an application that uses @RefreshScope . I would like to add a test that actually changes out properties and asserts that the application responds correctly. I have figured out how to trigger the refresh (autowiring in RefreshScope and calling refresh(...) ), but I haven't figured out a way to modify the properties. If possible, I'd like to write directly to the properties source (rather than having to work with files), but I'm not sure where to look. Update Here

Changing Spring Boot Properties Programmatically

我是研究僧i 提交于 2020-01-07 03:08:17
问题 I'm trying to write tests for an application that uses @RefreshScope . I would like to add a test that actually changes out properties and asserts that the application responds correctly. I have figured out how to trigger the refresh (autowiring in RefreshScope and calling refresh(...) ), but I haven't figured out a way to modify the properties. If possible, I'd like to write directly to the properties source (rather than having to work with files), but I'm not sure where to look. Update Here

Using Hystrix Stream in Zuul with Eureka First to find Config server

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 20:09:50
问题 I'm using spring cloud Brixton.M4 with spring boot 1.3.1 I have zuul server with <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-netflix-hystrix-stream</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-stream-rabbit</artifactId> </dependency> and i'm using Eureka first to find Config-Server so bootstrap looks like spring: profiles: dev cloud: config: fail-fast: true discovery: enabled: true