您的位置:首页 > 编程语言 > Java开发

springcloud碎碎念

2016-01-27 15:15 525 查看

spring-cloud

初步了解:

Spring Cloud 为开发者提供了在分布式系统(如配置管理、服务发现、断路器、智能路由、微代理、控制总线、一次性 Token、全局锁、决策竞选、分布式会话和集群状态)操作的开发工具。使用 Spring Cloud 开发者可以快速实现上述这些模式。

官网介绍:http://projects.spring.io/spring-cloud/

官方文档:http://projects.spring.io/spring-cloud/spring-cloud.html

git地址:https://github.com/spring-cloud/

组成部分

Spring Cloud Config:分布式配置文件管理,非常有用

Spring Cloud Netflix:对netfix的组件(Eureka, Hystrix, Zuul, Archaius, etc.)进行封装,大大优化了调用,搭配springboot很方便开发

Spring Cloud Bus

An event bus for linking services and service instances together with

distributed messaging. Useful for propagating state changes across a

cluster (e.g. config change events).

Spring Cloud for Cloud Foundry

Integrates your application with Pivotal Cloudfoundry. Provides a

service discovery implementation and also makes it easy to implement

SSO and OAuth2 protected resources, and also to create a Cloudfoundry

service broker.

Spring Cloud Cluster

Leadership election and common stateful patterns with an abstraction

and implementation for Zookeeper, Redis, Hazelcast, Consul

.

Spring Cloud Consul

Service discovery and configuration management with Hashicorp Consul.

Spring Cloud Security

Provides support for load-balanced OAuth2 rest client and

authentication header relays in a Zuul proxy.

Spring Cloud Sleuth

Distributed tracing for Spring Cloud applications, compatible with

Zipkin, HTrace and log-based (e.g. ELK) tracing.

Spring Cloud Data Flow

A cloud native programming and operating model for composable data

microservices on a structured platform.

Spring Cloud Stream

Messaging microservices with Redis, Rabbit or Kafka. Simple

declarative model to send and receive messages in a Spring Cloud app.

Spring Cloud Stream Modules

Spring Cloud Stream Modules can be used with Spring Cloud Stream to

create, build, and scale message-driven data microservices.

Spring Cloud Zookeeper

Service discovery and configuration management with Apache Zookeeper.

Spring Cloud for Amazon Web Services

Easy integration with hosted Amazon Web Services. It offers a

convenient way to interact with AWS provided services using well-known

Spring idioms and APIs, such as the messaging or caching API.

Developers can build their application around the hosted services

without having to care about infrastructure or maintenance.

Spring Cloud Connectors

Makes it easy for PaaS applications in a variety of platforms to

connect to backend services like databases and message brokers (the

project formerly known as “Spring Cloud”).

Spring Cloud Starters:spring-cloud的版本迭代比较快,是个大坑,自从有了Spring Cloud Starters可以快速使用maven去依赖某个jar 很方便

Spring Cloud CLI

Spring Boot CLI plugin for creating Spring Cloud component

applications quickly in Groovy

spring-boot

因为spring-cloud是在spring-boot基础上构建的,所以不得不深入了解spring-boot。

spring-boot 官网文档:

http://docs.spring.io/spring-boot/docs/current/reference/html/

spring-boot 常用配置项:

http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

微服务

因为公司说要搞微服务,刚好Netflix开源了他们使用的组件,所以就用咯

git地址:https://github.com/Netflix/

Netflix是一家成功实践微服务架构的互联网公司,几年前,Netflix就把它的几乎整个微服务框架栈开源贡献给了社区,这些框架和组件包括:


Eureka: 服务注册发现框架 Zuul: 服务网关 Karyon: 服务端框架 Ribbon: 客户端框架 Hystrix:

服务容错组件 Archaius: 服务配置组件 Servo: Metrics组件 Blitz4j: 日志组件

爬坑之路

如果自己要在短时间搭建一套微服务框架出来,第一自己能力不够,第二时间有限,第三没有实战项目的检验就算做出来也是坑。所以就打算用spring-cloud-netflix这一套。

如果要了解这些组件之间如何运作,有几种方式,英语好的那就官网一个组件一个组件的文档去看,然后写demo, 还可以用spring-cloud 自带的sample 快速跑起项目,不过官网的sample一般比较鸡肋,但是github已经有人帮我们搭建了一套


netflix-oss-example

github地址:https://github.com/Oreste-Luci/netflix-oss-example

这是别人搭建的example,介绍的比较好,也比较全,一张图说明一切



springcloudsamples-ggj

github地址:https://github.com/ggj2010/springcloudsamples-ggj

因为netflix-oss-example版本比较低,所以我就在他的基础上进行了一些升级,自己coding了一些代码进行理解

This example is using Spring Boot version 1.2.3.RELEASE and Spring Cloud version 1.0.0.RELEASE because there were some issues in Feign with the latest Spring Cloud version.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: