message driven microservices in the cloud

Post on 10-Feb-2017

2.574 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

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

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

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 FOUNDRY BOOT

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

M M M

M M

M

ZooKeeper Spring Cloud Data Flow (optional) SPI Implementation

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

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

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); } }

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 {}; }

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(); }

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 } }

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

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

Redis Ka!a

Channel Binders

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>

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

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; } }

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

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

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

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

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

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

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

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

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

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

top related