spring-cloud

spring-cloud with RestTemplate//Ribbon/Eureka - retry when server not available

戏子无情 提交于 2019-11-28 12:42:18
I managed to successfully get my RestTemplate client discover remote service using Eureka and forward calls to it using Ribbon as described in the documentation. Basically, it was just a matter of adding the following annotations of my Application class and let the magic of Spring-Boot do the rest: @Configuration @ComponentScan @EnableAutoConfiguration @EnableDiscoveryClient (PS: you noticed I'm using spring-cloud:1.0.0-SNAPSHOT-BUILD and not 1.0.0.M3 - but this doesn't seem to affect my problem). When two service instances are started, the rest-template client successfully load balance

Spring-Cloud configuration server ignores configuration properties file

大憨熊 提交于 2019-11-28 10:20:02
I am trying to create a Spring Cloud configuration server which reads the configuration data from the properties file and not a github. The server starts, but does not serve the properties from the file. I have two configuration files on the classpapath: bootstrap.yml spring: application: name: config-server config-server.properties foo=bar when I go to the url which supposedly should give me the value of the foo property: curl http://localhost:8888/admin/env/foo I get an error: "timestamp":1415298615005,"status":404,"error":"Not Found","exception":"org.springframework.boot.actuate.endpoint

EnableOAuth2Sso simultaneously for multiple social networks

随声附和 提交于 2019-11-28 09:05:04
问题 I am implementing a spring boot application that needs to provide OAuth2 token authorization and support multiple social services (google+, facebook etc). The user should be able to select his preferred social network and sign-in using the OAuth2 authorization framework. I am implementing the above using the approach described here http://cloud.spring.io/spring-cloud-security/. Currently my application.yml looks like this spring: oauth2: client: clientId: {{my app's google id} clientSecret: {

windows下新增项目本地通过git bash推送至远程github

北战南征 提交于 2019-11-28 08:11:05
  本地E盘workspace目录下新增了spring-cloud-alibaba-demo项目,还没有编译过,没有target等不需要推送至git的文件,所以就直接用git bash丢到github了。先在github上创建一个空项目,跟本地目录同名:   然后就纯命令行操作了,打开git bash: wulf@wulf00 MINGW64 /c/Users $ cd e: wulf@wulf00 MINGW64 /e $ cd workspace/spring-cloud-alibaba-demo/ wulf@wulf00 MINGW64 /e/workspace/spring-cloud-alibaba-demo $ git init Initialized empty Git repository in E:/workspace/spring-cloud-alibaba-demo/.git/ wulf@wulf00 MINGW64 /e/workspace/spring-cloud-alibaba-demo (master) $ git remote add origin https://github.com/wuxun1997/spring-cloud-alibaba-demo.git wulf@wulf00 MINGW64 /e/workspace/spring

Spring Cloud的Eureka实现服务发现注册和Feign实现服务调用

一个人想着一个人 提交于 2019-11-28 07:37:57
本篇博客主要讲解Eureka组件实现服务注册与发现和Feign组件实现服务间的调用的理论以及实际操作。 Eureka Eureka是Spring Cloud Netfix微服务套件中的一部分,可以和SpringBoot构建的微服务很容易的整合。SpringCloud将它集成在自己的子项目 spring-cloud-netflix中,实现SpringCloud的服务发现功能。 Eureka包含两个组件: Eureka Server(服务器端) 和 Eureka Client(客户端组件) 。 Eureka Server(服务器端组件) :也被称作服务注册中心,用于提高服务的注册和发现。各个节点启动后,会在Eureka Server中进行注册,这样EurekaServer中的服务注册表中将会存储所有可用服务节点的信息,服务节点的信息可以在界面中直观的看到。Eureka Server之间通过复制的方式完成数据的同步。 Eureka Client(客户端组件) :用于简化与Eureka Server的交互,包含服务消费者和服务生产者。客户端同时也有一个内置的、使用轮询(round-robin)负载算法的负载均衡器,在应用程序运行时,Eureka客户端向注册中心注册自身提供的服务并周期性的发送心跳来更新它的服务租约,向Eureka Server发送的心跳,默认周期为30秒,如果Eureka

Spring Cloud 之 Eureka集群整合Zuul、Feign

僤鯓⒐⒋嵵緔 提交于 2019-11-28 07:33:35
简介 Eureka是Spring Cloud Netflix微服务套件中的一部分,提供了服务治理的功能。Eureka集群中的节点基于REST服务进行通信,如使用HttpClient与RestTemplate,Spring Cloud 套件中的Feign模块提供了更为简洁的服务访问。 Zuul是一个网关,能够将集群的服务隐藏到网关后面,统一对外提供服务,功能上类似Nginx(部分类似),提升了集群的安全性。 集群结构 本示例共4个项目,分别为eureka-server、service-provider、service-invoker和zuul-server。其中,eureka-server为服务注册中心,端口号为8761;service-provider为服务提供者,端口号为9100;service-invoker为服务调用者,端口号为9000;zuul-server为网关,端口号为8080。 1、构建Eureka服务器 创建名为eureka-server的maven项目,或者使用eclipse(idea)的Springboot生成器创建Springboot项目。pom.xml文件如下: < parent > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter

spring-cloud的zuul案例

梦想与她 提交于 2019-11-28 07:28:04
为什么要使用微服务网关 简单来说,微服务网关是微服务架构中一个不可或缺的部分。通过服务网关统一向外系统提供REST API的过程中,除了具备服务路由、均衡负载功能之外,它还具备了权限控制等功能。 API网关是什么 API网关可以提供一个单独且统一的API入口用于访问内部一个或多个API。简单来说嘛就是一个统一入口,比如现在的支付宝或者微信的相关api服务一样,都有一个统一的api地址,统一的请求参数,统一的鉴权。 客户端和服务端直连的弊端 • 客户端会对此请求不同的微服务,增加客户端复杂性 • 存在跨域请求时,需要进行额外处理 • 认证服务,每个服务需要独立认证 • UI端和微服务耦合 网关的优缺点 优点: • 减少api请求次数 • 限流 • 缓存 • 统一认证 • 降低微服务的复杂度 • 支持混合通信协议(前端只和api通信,其他的由网关调用) • …… 缺点: • 网关需高可用,可能产生单点故障 • 管理复杂 Zuul实践 创建工程:spring-cloud-zuul。 这里直接加入了注册中心进行服务化模式。 0.加入pom依赖。 <!-- zuul 依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-zuul<

springcloud(五):熔断监控Hystrix Dashboard和Turbine

允我心安 提交于 2019-11-28 07:28:00
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。但是只使用Hystrix Dashboard的话, 你只能看到单个应用内的服务信息, 这明显不够. 我们需要一个工具能让我们汇总系统内多个服务的数据并显示到Hystrix Dashboard上, 这个工具就是Turbine. Hystrix Dashboard 我们在熔断示例项目spring-cloud-consumer-hystrix的基础上更改,重新命名为:spring-cloud-consumer-hystrix-dashboard。 1、添加依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency>

Spring Boot + Eureka Server + Hystrix with Turbine: empty turbine.stream

北城以北 提交于 2019-11-28 06:25:11
I'm trying to run Spring Boot (with Spring Cloud) + Eureka Server + Hystrix Dashboard and Turbine stream, but I run into a problem I couldn't find any solution so far. I use Spring Boot 1.2.1.RELEASE and Spring Cloud 1.0.0.RC2 . Here is what I have: The first instance is running Eureka server and Hystrix dashboard: @Configuration @EnableAutoConfiguration @EnableEurekaServer @EnableHystrixDashboard @EnableDiscoveryClient class Application { public static void main(String[] args) { SpringApplication.run Application, args } } Here you can find build.gradle for that instance - https://gist.github

springcloud(五):熔断监控Hystrix Dashboard和Turbine

风格不统一 提交于 2019-11-28 03:41:55
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。但是只使用Hystrix Dashboard的话, 你只能看到单个应用内的服务信息, 这明显不够. 我们需要一个工具能让我们汇总系统内多个服务的数据并显示到Hystrix Dashboard上, 这个工具就是Turbine. Hystrix Dashboard 我们在熔断示例项目spring-cloud-consumer-hystrix的基础上更改,重新命名为:spring-cloud-consumer-hystrix-dashboard。 1、添加依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency>