Date post: | 23-Jan-2018 |
Category: |
Technology |
Upload: | spring-by-pivotal |
View: | 2,354 times |
Download: | 0 times |
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Spring Cloud on AWSAgim Emruli
@aemruli
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Spring Cloud for AWS - History
2
1.01.0 M2 Angel Brixton Camden
ElasticSpring
1.0 M1
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Amazon Web Services
3
Core Cloud Services
Rich Platform Services
Developer Productivity
Compute Database Storage Networking
AnalyticsEnterprise Apps
Mobile Services
Internet of Things
Developer Tools
Manage- ment
Security Identity
Application Services
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Spring Cloud for AWS
4
Compute Database Storage Networking
AnalyticsEnterprise Apps
Mobile Services
Internet of Things
Developer Tools
Manage- ment
Security Identity
Application Services
Core Cloud Services
Rich Platform Services
Developer Productivity
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Spring Triangle
5
Simple ObjectD
epen
denc
y In
ject
ion Aspect-oriented D
ev
Portable Service Abstractions
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Dependency Injection with Environment
6
@Componentpublic class ApplicationInfoBean { @Value("${ami-id}") private String amiId; @Value("${hostname}") private String hostname; @Value("${instance-type}") private String instanceType; @Value("${services/domain}") private String serviceDomain; }
Meta-Data
Tags
User Meta-data
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Dependency Injection with Services
7
@EnableRdsInstance( dbInstanceIdentifier = “test”, password = “${user.password}“, readReplicaSupport = true) public static class AppConfig {}
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Amazon RDS Read-Replicas
8
Application
DataSource
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Amazon RDS Read-Replicas
9
Application
DataSource
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Read-replica Demarcation
10
@Servicepublic class JdbcPersonService implements PersonService { private final JdbcTemplate jdbcTemplate; @Autowired public JdbcPersonService(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); } @Transactional(readOnly = true) public List<Person> all() { return jdbcTemplate.query("SELECT * FROM Person”, … ); } @Transactional public void store(Person person) { jdbcTemplate.update("INSERT INTO Person …”); }}
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Spring Triangle
11
Simple ObjectD
epen
denc
y In
ject
ion Aspect-oriented D
ev
Portable Service Abstractions
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Simple Storage - Resource Loader Abstractionpublic class S3LoadingClass { @Autowired private ResourceLoader rl; public void download() { Resource resource = rl.getResource("s3://myBucket/myFile.txt"); resource.getInputStream(); } public void upload(){ WritableResource writableResource = (WritableResource) rl.getResource("s3://myBucket/newFile.txt"); writableResource.getOutputStream(); } }
12
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Simple E-Mail Service - Mail Senderpublic class MailSender { @Autowired private MailSender mailSender; @Test public void sendMail() throws Exception { SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setFrom(“[email protected]”); simpleMailMessage.setTo(“[email protected]”); simpleMailMessage.setSubject("test subject"); simpleMailMessage.setText("test content"); this.mailSender.send(simpleMailMessage); } }
13
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Elasticache - Caching
14
Application
Cache Manager
Application
Cache Manager
Redis
Memcached
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Caching Service Abstraction
@Service @EnableElastiCache( @CacheClusterConfig(name = “myCache”))public class ExpensiveService { @Cacheable("myCache") public String calculateExpensiveValue(String key){ return …; }}
15
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Amazon Simple Queueing Service
• HTTP-based messaging service
• Only String payloads
• Pay-per message (millions)
• No transactions
• Visibility rules
16
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Sending Messages with Spring Messaging@Service@EnableSqspublic class MessageSendingBean { private final QueueMessagingTemplate messagingTemplate; @Autowired public MessageSendingBean(AmazonSQS amazonSqs) { this.messagingTemplate = new QueueMessagingTemplate(amazonSqs); } public String sendAndReceive(String payload) { this.messagingTemplate.convertAndSend("requestQueue", payload); return this.messagingTemplate.
receiveAndConvert("resultQueue", String.class); } }
17
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Polling Message Using Container
@Component@EnableSqspublic class MessageReceivingBean { @SqsListener("receivingQueue") public @SendTo("responseQueue") Confirmation processEvent(CustomEvent customEvent){ return new Confirmation(); } }
18
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Acknowledgment@Component@EnableSqspublic class MessageReceivingBean { @SqsListener(value = "receivingQueue", deletionPolicy = NEVER) public @SendTo("responseQueue") Confirmation processEvent( CustomEvent customEvent, Acknowledgment acknowledgment){ if(successful){ acknowledgment.acknowledge(); } return new Confirmation(); } }
19
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Combining AWS Services
20
Amazon Elastic Transcoder
Amazon CloudWatch
Amazon S3Application
Listener
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
HTTP-based Notifications with Amazon SNS
21
Amazon SNSApplication
ControllerSubscribeConfirm
EventDelete
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Spring MVC - SNS Controller@RestController@RequestMapping("/sns/receive") public class SnsEndpointController { @NotificationSubscriptionMapping public void confirmSubscription( NotificationStatus notificationStatus) { notificationStatus.confirmSubscription(); } @NotificationMessageMapping public void receiveNotification( @NotificationMessage String message, @NotificationSubject String subject) { }}
22
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Deployment using Cloud Formation
23
Template Cloud Formation Application
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Cloud Formation Auto Configuration
24
Application
spring-cloud-aws-autoconfigure
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-aws-autoconfigure</artifactId> </dependency>
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Auto Config Services@Servicepublic class ApplicationBean { @Autowired private DataSource dataSource; @Autowired private MailSender mailSender; @Cacheable("myCache") public void cache(){ } @SqsListener("myQueue") public void receiveMessage(){ } }
25
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Pushing Metrics with Spring Boot Actuator
@Servicepublic class MetricProducer { @Autowired private CounterService counterService; public void sendOrder() { this.counterService.increment("orders"); } public void cancelOrder(){ this.counterService.decrement("orders"); } }
26
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Cloud Watch Visualization
27
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
The Future
28
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Spring Cloud Discovery Client
29
Application
Discovery Client API Gateway
Resources Methods
Consumer
Consumer
Consumer
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Spring Cloud Application
@SpringCloudApplicationpublic class SampleApplication { public static void main(String[] args) { SpringApplication.run(SampleApplication.class, args); }}
30
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Spring Cloud Controller
@Controllerpublic class SampleController { @RequestMapping("/person/{id}") public Person getPerson(@PathVariable String id) { return new Person("Agim", "Emruli"); }}
31
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
API Gateway Declaration
32
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Consuming API Gateway Services@Servicepublic class RestMoneyExchangeGateway implements MoneyExchangeGateway { @Autowired @LoadBalanced private RestOperations restTemplate; public Double exchangeMoney(String currency, long amount) { return restTemplate.getForObject(“http://MY-SERVICE/exchange/{currency}/{price}”, Double.class, currency, amount); }}
33
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
AWS Lambda Supportpublic class LambdaExample implements RequestHandler<S3EventNotification, String> { @Override public String handleRequest(S3EventNotification input, Context context) { return "result"; } }
34
@Servicepublic class LambdaTest { @LambdaFunction public String receiveNotification(S3EventNotification input) { return "test"; } }
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Lambda Function Structure
35
AWS Lambda
API Gateway
IOT
Kinesis
Trigger
Application
Lambda Function
Spring Beans
Lambda Handler
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Learn More. Stay Connected.
https://github.com/spring-cloud/spring-cloud-aws/
Cloud Native Java with Spring Cloud Services
@springcentral spring.io/blog
@pivotal pivotal.io/blog
@pivotalcf http://engineering.pivotal.io