Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Message Driven Microservices in the Cloud

3,160 views

Published on

From SpringOne2GX 2015.
Data / Integration Track

Do you need to build cloud-native microservices for distributed stream processing and data integration but don't know where to start? All you need is a single annotation in your code and a single dependency in your POM. The new Spring Cloud Stream project combines the power of Spring Boot, Spring Integration, and Spring Cloud to make that a reality.

In a nutshell, Spring Cloud Stream provides support for auto-configuration of Spring Integration capabilities, such as Channel Adapters for Kafka, RabbitMQ and Redis. The apps you build sit on a profile-driven foundation that ensures portability across runtime environments from your laptop to the cloud. Once you scale those distributed apps, you'll appreciate the integrated Spring Cloud features such as service discovery and configuration management.

This session will feature a series of live demos on different platforms ranging from local to a remote Cloud to show the simplicity of the Spring Cloud Stream developer experience. We will also dive into the details of what's happening behind the scenes. There will be stories about the background of how this project got started and its relevance for the evolution of Spring XD, as the latter has itself embarked on a cloud-native microservice journey.

Published in: Technology

Message Driven Microservices in the Cloud

  1. 1. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ SPRINGONE2GX WASHINGTON, DC Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Message-Driven Microservices (in the Cloud) Mark Fisher & Dave Syer @m_f_ @david_syer
  2. 2. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Safe Harbor Statement The following is intended to outline the general direction of Pivotal's offerings. It is intended for information purposes only and may not be incorporated into any contract. Any information regarding pre-release of Pivotal offerings, future updates or other planned modifications is subject to ongoing evaluation by Pivotal and is subject to change. This information is provided without warranty or any kind, express or implied, and is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions regarding Pivotal's offerings. These purchasing decisions should only be based on features currently available. The development, release, and timing of any features or functionality described for Pivotal's offerings in this presentation remain at the sole discretion of Pivotal. Pivotal has no obligation to update forward looking information in this presentation. 2
  3. 3. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Contents •  Background •  Quick Code Tour •  Channel Binders •  Configuration Properties •  Partitioning •  Portability •  Composition •  Orchestration 3
  4. 4. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Background 4 DIRT CLOUD NATIVE XD-CONTAINER ZOOKEEPER PLUGINS MICROSERVICES STREAM TASK LATTICE CLOUD FOUNDRYBOOT
  5. 5. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 5 Container Container Spring XD 1.x Host Spring Cloud Stream •  Modules run inside containers •  Container is a Boot app •  Modules are ApplicationContexts •  Modules are executable Boot apps •  Easier to use Spring Cloud features •  Easier to test, consistent dev experience •  Portable and “cloud-native” M Host M M M MM M M M M ZooKeeper Spring Cloud Data Flow (optional) SPI Implementation
  6. 6. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 6 •  OOTB modules •  Executable Boot Apps •  Boot for Spring Integration and Batch •  Auto-Configuration, Bindings XD Container Modules Admin Spring Cloud Data Flow Spring Cloud Stream Modules Spring Cloud Task Modules Spring Cloud Stream Spring Cloud Task •  REST API, Shell, UI •  Module Deployer SPI: •  Singlenode •  Lattice •  YARN •  Cloud Foundry From Monolith to Microservices
  7. 7. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 7
  8. 8. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 8 @EnableBinding(Source.class) public class Greeter { @InboundChannelAdapter(Source.OUTPUT) public String greet() { return "hello world"; } } @EnableBinding(Sink.class) public class Logger { @ServiceActivator(inputChannel=Sink.INPUT) public void log(String message) { System.out.println(message); } }
  9. 9. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 9 @Import({...Configuration Classes...}) @EnableIntegration public @interface EnableBinding { /** * A list of interfaces having methods annotated with {@link Input} * and/or {@link Output} to indicate bindable components. */ Class<?>[] value() default {}; }
  10. 10. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 10 public interface Source { String OUTPUT = "output"; @Output(Source.OUTPUT) MessageChannel output(); } public interface Sink { String INPUT = "input"; @Input(Sink.INPUT) SubscribableChannel input(); }
  11. 11. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 11 @EnableBinding(Source) class Greeter { @InboundChannelAdapter(Source.OUTPUT) String greet() { 'hello world' } } @EnableBinding(Sink) class Logger { @ServiceActivator(inputChannel=Sink.INPUT) void log(String msg) { println msg } }
  12. 12. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ DEMO: Hello World 12
  13. 13. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 13 time log $ java –jar time-source.jar $ java –jar log-sink.jar Boot App Rabbit Boot App Binder RedisKafka Channel Binders
  14. 14. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Channel Binder Starters 14 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-stream-kafka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-stream-rabbit</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-stream-redis</artifactId> </dependency>
  15. 15. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ DEMO: Channel Binders 15
  16. 16. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Configuration Properties 16 @EnableBinding(Source.class) @EnableConfigurationProperties(TimeSourceProperties.class) public class TimeSource { @Autowired private TimeSourceProperties properties; ... } @ConfigurationProperties public class TimeSourceProperties { private String format = "yyyy-MM-dd HH:mm:ss"; @DateFormat public String getFormat() { return this.format; } public void setFormat(String format) { this.format = format; } }
  17. 17. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ DEMO: Configuration Properties 17
  18. 18. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Partitioning 18 $ java –jar http-source.jar --server.port=9000 --spring.cloud.stream.bindings.output.destination=demo --spring.cloud.stream.bindings.output.partitionKeyExpression=payload --spring.cloud.stream.bindings.output.partitionCount=2 $ java -jar log-sink.jar --server.port=8081 --spring.cloud.stream.bindings.input.destination=demo --spring.cloud.stream.bindings.input.partitioned=true --spring.cloud.stream.instanceIndex=0 --spring.cloud.stream.instanceCount=2 $ java -jar log-sink.jar --server.port=8082 --spring.cloud.stream.bindings.input.destination=demo --spring.cloud.stream.bindings.input.partitioned=true --spring.cloud.stream.instanceIndex=1 --spring.cloud.stream.instanceCount=2
  19. 19. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ DEMO: Partitioning Streams 19
  20. 20. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Runtime Portability •  Spring Boot Property Binding •  command-line args •  System Properties •  Environment Variables •  Properties/YAML Files •  Spring Profiles •  cloud •  lattice •  Spring Boot Auto Configuration •  Spring Cloud Connectors 20
  21. 21. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ DEMO: Cloud Deployment 21
  22. 22. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 22
  23. 23. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ spring-cloud-dataflow 23
  24. 24. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 24
  25. 25. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ DEMO: Spring Cloud Data Flow 25
  26. 26. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 26 Cloud Native Data Flow Orchestration: Wednesday 8:30-10am Learn More. Stay Connected. @springcentral Spring.io/video

×