In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to configure Spring Cloud". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to configure Spring Cloud.
Preface
Spring Cloud provides some general tools for building distributed systems and micro services, such as configuration center, service registration and discovery, fuses, routing, agents, control bus, one-time tokens, global locks, leader elections, distributed sessions, cluster state, etc.
At present, many domestic companies still use dubbo for service decomposition, but dubbo only provides service registration discovery function, and it is necessary to find corresponding tools for combination if you want to build a distributed system. Of course, this is customized and flexible, but some technologies need to be touched, and Ali has stopped updating dubbo.
If using the Spring Cloud technology stack, Spring Cloud provides about most of the common modules and functions needed in distributed systems and micro-services
All the projects under Spring Cloud are based on Spring Boot, so if you want to use Spring Cloud for microservice development, you'd better master Spring Boot first.
The following table shows the comparison of dubbox and Spring Cloud technology stacks
Functional DubboxSpring Cloud service registry ZookeeperSpring Cloud Netflix Eureka service invocation mode RPC/REST APIREST API service gateway no Spring Cloud Netflix Zuul fuse imperfect Spring Cloud Netflix Hystrix distributed configuration no Spring Cloud Config service tracking no Spring Cloud Sleuth message bus no Spring Cloud Bus data flow no Spring Cloud Stream batch task no Spring Cloud TaskSpring Cloud Cluster
Abstraction and implementation of Zookeeper,Redis,Hazelcast,Consul 's leader election and common state patterns.
Brief introduction
Spring Cloud provides developers with tools to quickly build some common patterns (patterns) in distributed systems (such as configuration management, service discovery, fuses, intelligent routing, micro-agents, control bus (control bus), one-time tokens, global locks, leader elections, distributed sessions, cluster state). The coordination of distributed systems leads to the boiler plate pattern (boiler plate patterns), and developers using Spring Cloud can quickly develop (stand up) services and applications that implement these patterns. The program will run well in any distributed environment, including developers' own laptops, bare metal data centers, and hosting platforms like Cloud Foundry.
Spring Cloud is based on Spring Boot and can enhance the behavior of applications by providing a set of class libraries. You can take advantage of the basic default behavior (behaviour) / configuration Quick start, and then you can configure or extend it as needed to create a custom solution.
Quickly start the org.springframework.boot spring-boot-starter-parent 1.4.5.RELEASE org.springframework.cloud spring-cloud-dependencies Camden.SR6 pom import org.springframework.cloud spring-cloud-starter-config org.springframework.cloud spring-cloud-starter-eureka function
Spring Cloud is committed to providing a good out-of-the-box experience for typical use cases and extension mechanisms.
Distributed / versioned configuration
Service registration and discovery
Routin
Service to service (Service-to-service) invocation
Load balancing
Fuse (Circuit Breakers)
Global lock
Leader election and cluster status
Distributed message
Spring Cloud takes the form of annotated declarations, which usually require only a classpath and / or explain the changes to get a lot of functionality. As an example application for discovery clients:
@ SpringBootApplication@EnableDiscoveryClientpublic class Application {public static void main (String [] args) {SpringApplication.run (Application.class, args);}} Spring Cloud Config
Unified configuration management supported by the git repository. Configuration resources map directly to SpringEnvironment, but non-Spring applications can be used if desired.
Brief introduction
Spring Cloud Config provides server and client support for external unified configuration centers in distributed systems. With Config Server, you can manage the external (externalized) configuration properties of your application in all environments. The concept of client and server mapping is the same as Spring Environment and PropertySource abstractions, so they fit well with Spring applications, but can be used with applications in any language. As the application is deployed from the development environment to the test environment and the production environment, you can manage the configuration between these environments and determine that all configuration properties are required when the application is migrated from environment to environment. The default implementation on the storage side of the server uses git, so it can easily support a tagged version of the configuration environment, as well as a variety of tools that can access content for management. You can easily add an alternative implementation and insert it using the Spring configuration.
Function
Spring Cloud Config Server function:
External configuration API based on HTTP resources (name / value pairs or equivalent YAML content)
Encrypt and decrypt attribute values (symmetric or asymmetric)
You can easily embed Spring Boot applications using @ EnableConfigServer
Config Client features (for Spring applications):
Bind to Config Server and initialize Spring Environment with a remote property source
Encrypt and decrypt attribute values (symmetric or asymmetric)
Quick start
Take using Maven as an example of project dependency management:
Org.springframework.cloud spring-cloud-config 1.3.1.BUILD-SNAPSHOT pom import org.springframework.cloud spring-cloud-starter-config spring-snapshots Spring Snapshots https://repo.spring.io/libs-snapshot true
As long as the Spring Boot Actuator and Spring Config Client class libraries are in the classpath, any Spring Boot application will attempt to connect to the configuration server of http://localhost:8888 (the default for spring.cloud.config.uri):
@ Configuration@EnableAutoConfiguration@RestControllerpublic class Application {@ Value ("${config.name}") String name = "World"; @ RequestMapping ("/") public String home () {return "Hello" + name;} public static void main (String [] args) {SpringApplication.run (Application.class, args);}}
The value of config.name in the example (or any other value that is normally bound in Spring Boot) can come from a local configuration or a remote Config Server. By default, Config Server takes precedence. To view the / env endpoint in the application, see the configServer property source.
To run your own server, use the spring-cloud-config-server dependency and the @ EnableConfigServer annotation. If you set up spring.config.name=configserver, the application will run on port 8888 and provide data from the sample repository (sample repository). You need a spring.cloud.config.server.git.uri to find the configuration data you need (by default, it is the location of the git repository, which can be a local url:.. URL).
Spring Cloud Netflix
Integrate various Netflix OSS components (Eureka, Hystrix, Zuul, Archaius, etc.).
Brief introduction
Spring Cloud Netflix provides Netflix OSS integration for Spring Boot applications through automatic configuration, binding to Spring Environment, and other Spring programming model syntax. With a few simple annotations, you can quickly enable and configure common patterns in your application and build large distributed systems using proven Netflix components. Common patterns provided include service discovery (Eureka), break mechanism (Hystrix), intelligent routing (Zuul), and client load balancing (Ribbon).
Function
Spring Cloud Netflix function:
Service Discovery: Eureka instances can be registered, and clients can use bean managed by Spring to discover instances
Service Discovery: you can create an embedded Eureka server using a declarative Java configuration
Break mechanism: Hystrix clients can be built using a simple annotation-driven method decorator
Melting mechanism: embedded Hystrix dashboard with declarative Java configuration
Declarative REST client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations
Client load balancer: Ribbon
External configuration: bridge from Spring Environment to Archaius (enable local configuration of Netflix components using the Spring Boot convention)
Routers and filters: automatic registration of Zuul filters and a simple configuration method for reverse proxy creation
Quick start
Maven:
Org.springframework.cloud spring-cloud-netflix 1.3.1.BUILD-SNAPSHOT pom import org.springframework.cloud spring-cloud-starter-eureka spring-snapshots Spring Snapshots https://repo.spring.io/libs-snapshot true
As long as the Spring Cloud Netflix and Eureka Core class libraries are in the classpath, any Spring Boot application with @ EnableEurekaClient will try to connect to the Eureka server on http://localhost:8761 (the default for eureka.client.serviceUrl.defaultZone):
@ Configuration@EnableAutoConfiguration@EnableEurekaClient@RestControllerpublic class Application {@ RequestMapping ("/") public String home () {return "Hello World";} public static void main (String [] args) {SpringApplication.run (Application.class, args);}}
To run your own server, add the dependency spring-cloud-starter-eureka-server and @ EnableEurekaServer annotations.
Spring Cloud Bus
An event bus used to link services and service instances as well as distributed messaging. Used to propagate state changes (such as configuration change events) in the cluster.
Brief introduction
Spring Cloud Bus connects nodes of distributed systems to lightweight message agents. This can be used to broadcast state changes (such as configuration changes) or other administrative instructions. Currently, the only implementation is to use the AMQP proxy as the transport, but the same basic feature set (and some depending on the transport) is on the roadmap of other transports.
Quick start
Maven:
Org.springframework.cloud spring-cloud-bus-parent 1.3.0.M1 pom import org.springframework.cloud spring-cloud-starter-bus-amqp spring-milestones Spring Milestones https://repo.spring.io/libs-milestone false
As long as the Spring Cloud Bus AMQP and RabbitMQ class libraries are in the classpath, any Spring Boot application will attempt to connect to the RabbitMQ server on localhost:5672 (the default for spring.rabbitmq.addresses):
@ Configuration@EnableAutoConfiguration@RestControllerpublic class Application {@ RequestMapping ("/") public String home () {return "Hello World";} public static void main (String [] args) {SpringApplication.run (Application.class, args);}} Spring Cloud for Cloud Foundry
Integrate your application with Pivotal Cloudfoundry. Service discovery implementation is provided, and resources protected by SSO and OAuth3 can be easily implemented, and Cloudfoundry service proxies can be created.
Brief introduction
Spring Cloud for Cloudfoundry can easily run Spring Cloud applications in Cloud Foundry (platform as a Service). Cloud Foundry has a concept of "service", which is middleware that is "bound" to the application, essentially providing it with environment variables containing credentials (for example, the location and user name for the service).
Function
The spring-cloud-cloudfoundry-web project provides basic support for some enhancements to webapps in Cloud Foundry: automatic binding to a single sign-on service and optionally enabling sticky routing for discovery.
The spring-cloud-cloudfoundry-discovery project provides an implementation of Spring Cloud Commons DiscoveryClient, so you can @ EnableDiscoveryClient and will provide your credentials spring.cloud.cloudfoundry.discovery. [email,password], which can then be used either directly with DiscoveryClient or through a LoadBalancerClient (also * .url if you are not connected to Pivotal Web Services).
Note: if you are looking for a way to bind to a service, this is the wrong library. Check the Spring Cloud connector.
Quick start
Maven:
Org.springframework.cloud spring-cloud-cloudfoundry-web 1.0.2.BUILD-SNAPSHOT spring-snapshots Spring Snapshots https://repo.spring.io/libs-snapshot true Spring Cloud Cloud Foundry Service Agent
Provides a starting point for building a service agent that manages Cloud Foundry management services.
Brief introduction
Spring Cloud Cloud Foundry Service Broker is the framework for building Spring Boot applications that implement Cloud Foundry Service Broker API and manage the services provided in Cloud Foundry Marketplace.
The service managed by Cloud Foundry is managed by the service agent, which notifies the service plan provided by the service, and provides, destroys, binds and unbinds the service instance. Spring Cloud Cloud Foundry Service Broker provides a Spring Boot-based framework that allows you to quickly create proxies for your own managed services on Cloud Foundry.
Function
Default configuration for directory and service binding / unbinding endpoints
Support for asynchronous service operations (Cloud Foundry Service Broker API 2.7)
Support for any parameters provided to the cf Command Line Interface tool
Support for Cloud Foundry routing services
Quick start
Maven:
Org.springframework.cloud spring-cloud-cloudfoundry-service-broker 1.0.0.RELEASE
To enable the default configuration of the Spring Cloud Cloud Foundry Service Broker framework, your proxy application only needs to use the @ EnableAutoConfiguration or @ SpringBootApplication annotation in its main application class:
@ SpringBootApplicationpublic class Application {public static void main (String [] args) {SpringApplication.run (Application.class, args);}}
For more information about the interfaces that implement API functionality and the default implementation provided, refer to the project documentation. For more information about developing Cloud Foundry management services, see the Cloud Foundry documentation.
Spring Cloud Consul
Hashicorp Consul service discovery and configuration management.
Brief introduction
The project provides Consul integration for Spring applications through automatic configuration, binding to Spring Environment and other Consul programming model syntax. With a few simple comments, you can quickly enable and configure common patterns in your application and build large distributed systems using Consul-based components. The modes provided include service discovery, control bus, and configuration. Intelligent routing (Zuul) and client load balancing (ribbon), and circuit breakers (Hystrix) are provided through integration with Spring Cloud Netflix.
Spring Cloud Security
OAuth3 rest client and authentication header forwarding of load balancing are supported in the Zuul proxy.
Brief introduction
Spring Cloud Security provides a set of native language-level applications and minimization services for building security. A declarative model that can be highly configured externally (or centrally) is suitable for the implementation of large cooperative remote component systems that usually use central contract management services. It is also easy to use on service platforms like Cloud Foundry. Based on Spring Boot and Spring Security OAuth3, we can quickly create systems that implement common modes such as single sign-on, token relay and token exchange.
Function
Forward SSO tokens from the front end to the back-end service in the Zuul proxy
Relay tokens between resource servers
An interceptor can make a Feign client behave like OAuth3RestTemplate (get tokens, etc.)
Configure downstream authentication in the Zuul agent
Quick start
Maven:
Org.springframework.cloud spring-cloud-security 1.1.4.BUILD-SNAPSHOT spring-snapshots Spring Snapshots https://repo.spring.io/libs-snapshot true
If your application also has an Spring Cloud Zuul embedded reverse proxy (using @ EnableZuulProxy), you can ask it to forward the OAuth3 access token to its proxy server. Therefore, the above SSO application can be simply enhanced:
@ SpringBootApplication@EnableOAuth3Sso@EnableZuulProxyclass Application {}
And (in addition to recording the user and grabbing the token), the authentication token will also be passed down to the / proxy/* service. If these services are implemented with @ EnableResourceServer, they will get a valid token in the correct header.
Spring Cloud Data Flow
Modern runtime composable microservice applications are native to cloud (cloud-native) orchestration services. Easy-to-use DSL, drag-and-drop GUI and REST API work together to simplify the overall orchestration of micro-service-based data pipelines.
Brief introduction
Spring Cloud Data Flow is a native cloud (cloud-native) orchestration service for modern runtime composable micro-service applications. With Spring Cloud Data Flow, developers can create and orchestrate data pipelines (pipelines) for common use cases such as data collection, real-time analysis, and data import / export.
Spring Cloud Data Flow is a local Yunsheng redesign of Spring XD designed to simplify the development of Big Data applications. Spring XD's streaming and batch modules are refactored as Spring Boot-based streaming and task / batch microservice applications, respectively. These applications are now autonomous deployment units that can run "naturally" in modern runtime environments such as Cloud Foundry,Apache YARN,Apache Mesos and Kubernetes.
Spring Cloud Data Flow provides a range of patterns and best practices for micro-service-based distributed flows and task / batch data pipelining.
Function
Using DSL,REST-API, dashboards, and drag-and-drop GUI-Flo development
Create, unit test, troubleshoot, and manage microservice applications independently
Quickly build data pipelines using out-of-the-box streams and task / batch applications
Use a microservice application as a maven or docker artifact (artifacts)
Scale the data pipeline (pipelines) without interrupting the data flow
Coordinate data center applications on a variety of modern runtime platforms, including Cloud Foundry,Apache YARN,Apache Mesos and Kubernetes
Using indicators (metrics), health check remotely manages each microservice application
Quick start
Step 1-download Spring Cloud Data Flow's local server and Shell ü ber-jar:
Wget http://repo.spring.io/release/org/springframework/cloud/spring-cloud-dataflow-server-local/1.1.3.RELEASE/spring-cloud-dataflow-server-local-1.1.3.RELEASE.jarwget http://repo.spring.io/release/org/springframework/cloud/spring-cloud-dataflow-shell/1.1.3.RELEASE/spring-cloud-dataflow-shell-1.1.3.RELEASE.jar
Step 2-download and launch Kafka 0.10 [used as messaging middleware]
Step 3-start the local server
Java-jar spring-cloud-dataflow-server-local-1.1.3.RELEASE.jar
Step 4-start Shell on the same machine running the local server
Java-jar spring-cloud-dataflow-shell-1.1.3.RELEASE.jar
Step 5-Import provided applications from Shell
Dataflow: > app import-- uri http://bit.ly/Avogadro-SR1-stream-applications-kafka-10-maven
Step 6-create a 'ticktock' stream from Shell
Dataflow: > stream create ticktock-- definition "time | log"-- deploy
Once the "ticktock" stream is deployed, you will notice that the output is similar to that in the local server console [see Step 3]. For example, the log for the logging application will be located in the: / var/folders/./ticktock.log directory.
2016-07-18 22 INFO 08V 24.777 INFO 73058-[nio-9393-exec-9] o.s.c.d.spi.local.LocalAppDeployer: deploying app ticktock.log instance 0 Logs will be in / var/folders/c3/ctx7_rns6x30tq7rb76wzqwr0000gp/T/spring-cloud-dataflow-5011521526937452211/ticktock-1468904904769/ticktock.log2016-07-18 22 o.s.c.d.spi.local.LocalAppDeployer 0881 INFO 73058-[nio-9393-exec-9] o.s.c.d.spi. Local.LocalAppDeployer: deploying app ticktock.time instance 0 Logs will be in / var/folders/c3/ctx7_rns6x30tq7rb76wzqwr0000gp/T/spring-cloud-dataflow-5011521526937452211/ticktock-1468904905074/ticktock.time
Step 7-verify 'ticktock' Lo
Tail-f / var/folders/... / ticktock.log/stdout_0.log
Step 8-View the dashboard function of the local server: http://localhost:9393/dashboard
Spring Cloud Data Flow implementation
Local Server
Cloud Foundry Server
Apache YARN Server
Kubernetes Server
Apache Mesos Server
For the version, please refer to here.
Spring Cloud Data Flow Community Edition implementation
Spring Cloud Data Flow for HashiCorp Nomad
Spring Cloud Data Flow for Red Hat OpenShift
Spring Cloud Data Flow building module
Spring Cloud Data Flow is based on multiple projects, and the top-level building modules of the ecosystem are listed in the following visual representations. Each project represents a core function that is developed and released independently-you can find more details about each project according to the link.
Spring Cloud Stream
A lightweight event-driven micro-service framework to quickly build applications that can be connected to external systems. A simple declaration model that uses Apache Kafka or RabbitMQ to send and receive messages between Spring Boot applications.
Brief introduction
Spring Cloud Stream is a framework for building message-driven microservices. Spring Cloud Stream is built on top of Spring Boot to create DevOps-friendly microservice applications and Spring Integration to provide connectivity to message brokers. Spring Cloud Stream provides its own message broker configuration, introducing persistent concepts of pub/sub semantics, consumer groups, and partitions among multiple middleware vendors. This built-in configuration provides the basis for creating a streaming application.
By adding @ EnableBinding to the main application, you can connect to the message broker immediately, and by adding @ StreamListener to the method, you will receive stream processing events.
Quick start
Maven:
Org.springframework.cloud spring-cloud-stream-dependencies Brooklyn.SR3 pom import org.springframework.cloud spring-cloud-stream org.springframework.cloud spring-cloud-starter-stream-kafka
As long as Spring Cloud Stream and Spring Cloud Stream binder are in the classpath, any Spring Boot application with @ EnableBinding will bind to an external proxy provided by the bus (for example, Rabbit MQ or Kafka, depending on the implementation of your choice). Example:
Go to http://start.spring.io and create a project with "Stream Kafka" dependencies. Modify the main class as follows:
@ SpringBootApplication@EnableBinding (Source.class) public class StreamdemoApplication {public static void main (String [] args) {SpringApplication.run (StreamdemoApplication.class, args);} @ Bean @ InboundChannelAdapter (value = Source.OUTPUT) public MessageSource timerMessageSource () {return ()-> new GenericMessage (new SimpleDateFormat (). Format (new Date ());}}
When running the application, make sure that Kafka is running. You can use the kafka-console-consumer.sh script provided by Kafka to monitor messages sent on the output topic.
Spring Cloud Stream App Starters
The Spring Cloud Stream App Starters Application launcher is a Spring Boot-based Spring integration application that provides integration with external systems.
Brief introduction
The Spring Cloud Stream Application launcher is a Spring Boot-based Spring integration application that provides integration with external systems. Spring Cloud Stream applications can be used with Spring Cloud Data Flow to create, deploy, and orchestrate message-driven microservice applications.
Spring Cloud Stream Application Starters is a stand-alone executable application that communicates through messaging middleware such as Apache Kafka and RabbitMQ. These applications can run independently on a variety of runtime platforms, including Cloud Foundry,Apache Yarn,Apache Mesos,Kubernetes,Docker and even your laptop.
Function
Run independently as a Spring Boot application
Assemble microservices into pipeline flows in Spring Cloud Data Flow
Use a micro-service application as a maven or docker artifacts
Override configuration parameters through the command line, environment variables, or YAML files
Provide infrastructure to isolate test applications
Download version Spring Initializr as initiator
Available application SourceProcessorSink (sink) fileaggregatoraggregate-counterftpbridgecassandragemfirefiltercountergemfire-cqgroovy-filterfield-value-counterhttpgroovy-transformfilejdbchttpclientftpjmspmmlgemfireload-generatorscriptable-transformgpfdistloggregatorsplitterhdfsmailtasklaunchrequest-transformhdfs-datasetmongodbtcp-clientjdbcrabbittransformlogs3
Mongodbsftp
Pgcopysyslog
Rabbittcp
Redis-pubsubtcp-client
Routertime
S3trigger
Sftptriggertask
Task-launcher-cloudfoundrytwitterstream
Task-launcher-local
Task-launcher-yarn
Tcp
Throughput
Websocket
Quick start
Step 1-download the latest Kafka 10-based Time Source application here [eg: / 1.1.1.RELEASE/time-source-kafka-10-1.1.1.RELEASE.jar]
Step 2-download the latest Kafka 10-based log-sink application here [eg: / 1.1.1.RELEASE/log-sink-kafka-10-1.1.1.RELEASE.jar]
Step 3-launch Kafka 0.10.1.0
Step 4-run Time Source and bind to the ticktock theme
Java-jar time-source-kafka-***.jar-- spring.cloud.stream.bindings.output.destination=ticktock
Step 5-run Log Sink and bind to ticktock Topic
Java-jar log-sink-kafka-***.jar-- spring.cloud.stream.bindings.input.destination=ticktock
Step 6-verify Tickets Logs on the console
Stream App Starters and Spring Cloud Data Flow (* *)
See the end of the official website.
Spring Cloud Task
A short-term micro-service framework for quickly building applications that perform limited data processing. A simple declaration to add functional and non-functional features to the Spring Boot application.
Brief introduction
Spring Cloud Task allows users to develop and run short-term microservers using Spring Cloud, and run them in the cloud, or even in Spring Cloud Data Flow. Just add @ EnableTask and run your application as a Spring Boot application (a single application context).
Quick start
Maven:
Org.springframework.cloud spring-cloud-task-starter 1.1.2.RELEASE
As long as Spring Cloud Task is in the classpath, any Spring Boot application with @ EnableTask will record the start and end of the bootstrap application and any uncaught exceptions in the configured task repository. Example:
@ SpringBootApplication@EnableTaskpublic class ExampleApplication {@ Bean public CommandLineRunner commandLineRunner () {return strings-> System.out.println ("Executed at:" + new SimpleDateFormat () .format (new Date () } public static void main (String [] args) {SpringApplication.run (ExampleApplication.class, args);}} Spring Cloud Task App Starters
Spring Cloud Task application launchers are Spring Boot applications that can be any process, including Spring Batch jobs that do not run permanently, and end / stop in limited data processing time.
Brief introduction
The Spring Cloud task application initiator is a Spring Boot application, which can be any process, including Spring Batch jobs that will not run permanently, and will end / stop at some point. Spring Cloud Task applications can be used with Spring Cloud Data Flow to create, deploy, and orchestrate short-term data microservers.
The Spring Cloud Task Application launcher is a stand-alone executable application that can be used for on-demand usage such as database migration, machine learning, and scheduled operations. These applications can run independently on a variety of runtime platforms, including Cloud Foundry,Apache Yarn,Apache Mesos,Kubernetes,Docker and even your laptop.
Function
Run independently as a Spring Boot application
Coordinate for short-term data micro-services
Use a data microservice application as a maven or docker artifacts
Override configuration parameters through the command line, environment variables, or YAML files
Provide infrastructure to isolate test applications
Download this version of Spring Initializr as the initiator
Available applications
Spark-client
Spark-cluster
Spark-yarn
Timestamp
Quick start
Step 1-download the latest timestamp application here [eg: / 1.1.0.RELEASE/timestamp-task-1.1.0.RELEASE.jar]
Step 2-run the timestamp program
Java-jar timestamp-task-***.jar
Step 3-verify the timestamp log in the console
Step 4-verify that the timestamp application is closed
Task App Starters and Spring Cloud Data Flow (* *)
The bottom of the official website
Spring Cloud Zookeeper
Use Apache Zookeeper for service discovery and configuration management.
Brief introduction
Spring Cloud Zookeeper provides Apache Zookeeper integration for Spring Boot applications by automatically configuring and binding to Spring Environment and other Spring programming model syntax. With a few simple comments, you can quickly enable and configure common patterns in your application and build large distributed systems using Zookeeper. The patterns provided include service discovery and distributed configuration.
Function
Service discovery: you can register the instance with Zookeeper, and the client can use bean managed by Spring to discover the instance
Support for client-side load balancer Ribbon through Spring Cloud Netflix
Support for Zuul, dynamic routers and filters through Spring Cloud Netflix
Distributed configuration: using Zookeeper as data store
Quick start
Maven:
Org.springframework.cloud spring-cloud-zookeeper-dependencies 1.0.3.RELEASE pom import org.springframework.cloud spring-cloud-zookeeper-discovery
As long as Spring Cloud Zookeeper,Apache Curator and Zookeeper Java Client are in the classpath, any Spring Boot application with @ EnableDiscoveryClient will try to connect to the Zookeeper agent on http://localhost:2181 (the default for zookeeper.connectString).
@ Configuration@EnableAutoConfiguration@EnableDiscoveryClient@RestControllerpublic class Application {@ RequestMapping ("/") public String home () {return "Hello World";} public static void main (String [] args) {SpringApplication.run (Application.class, args);}} introduction to Spring Cloud for Amazon Web Services
Easy integration with managed Amazon Web Services. It provides a convenient way to interact with services provided by AWS using the well-known common syntax of Spring and API (such as messaging or caching API). Developers can build applications around managed services without concern for infrastructure or maintenance.
Function
Spring Messaging API implementation of SQS.
Spring Cache API implementation of ElastiCache.
Annotation-based mapping of SNS endpoints (HTTP).
Access resources through the logical names they define in the CloudFormation stack.
Create an automatic JDBC DataSource based on the logical name of the RDS instance.
Ant style path matching for S3 barrel ResourceLoader.
Annotation-based SQS Queue Listener
@ MessageMapping ("logicalQueueName") private void receiveMessage (Person person, @ Header ("SenderId") String senderId) {/ /.}
Annotation-based SNS Listener
@ Controller@RequestMapping ("/ sns/receive") public class SnsEndpointController {@ NotificationMessageMappingpublic void receiveNotification (@ NotificationMessage String message, @ NotificationSubject String subject) {/ /...} @ NotificationSubscriptionMappingpublic void confirmSubscription (NotificationStatus notificationStatus) {notificationStatus.confirmSubscription ();}
Messaging Templates
SnsTemplate.sendNotification ("SnsTopic", "message", "subject"); sqsTemplate.convertAndSend ("Queue", new Person ("John", "Doe"); Quick start
Maven:
Org.springframework.cloud spring-cloud-aws 1.2.0.BUILD-SNAPSHOT pom import org.springframework.cloud spring-cloud-starter-aws spring-snapshots Spring Snapshots https://repo.spring.io/libs-snapshot true Spring Cloud Connectors
Make it easy for PaaS applications to connect to back-end services such as databases and message brokers (formerly known as "Spring Cloud") on various platforms.
Brief introduction
Spring Cloud connectors simplify the process of connecting to services and gain runtime support in cloud platforms such as Cloud Foundry and Heroku, especially for Spring applications. It is designed for extensibility: you can use one of the cloud connectors provided or write a connector for the cloud platform, and you can use the built-in common service support (relational database, MongoDB,Redis,RabbitMQ) or extended Spring cloud connector to work with your own services.
Function
The Spring Cloud connector focuses on providing a good out-of-the-box experience for typical use cases and provides an extensibility mechanism to cover other users.
Java and XML configuration for Spring applications: an easy way to create bean for services bound to an application.
Cloud platform scalability: the concept of cloud connectors that allows you to extend the capabilities of Spring Cloud connectors to other cloud platforms.
Service information and connector extensibility: your own Spring Cloud connector extension can connect an application to any service by extracting service connection information from the application's operating environment, and optionally can convert the information into a service connector.
Constituent project
Spring Cloud Connectors Core: core class library. Cloud-agnostic, independent of Spring;, provides an entry point for application developers who choose to access cloud services and application information programmatically, and provides an extension mechanism for contributors to cloud connector and service connector creators.
Spring Cloud Service Connector: provides a library of service connector creators from the Spring Data project's javax.sql.DataSource and various connection factories.
Cloud Foundry Connector:Cloud Foundry cloud connector.
Cloud connector for Heroku Connector:Heroku.
Quick start
Maven:
Org.springframework.cloud spring-cloud-spring-service-connector 1.2.3.RELEASE org.springframework.cloud spring-cloud-cloudfoundry-connector 1.2.3.RELEASE org.springframework.cloud spring-cloud-heroku-connector 1.2.3.RELEASE
Then, if you are using a Spring application, follow Spring Cloud Spring Service Connector's instructions. If you do not use Spring, check out Spring Cloud Connectors Core.
Thank you for your reading, the above is the content of "how to configure Spring Cloud", after the study of this article, I believe you have a deeper understanding of how to configure Spring Cloud, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.