Cloud Foundry deployment

This commit is contained in:
Kenny Bastani
2017-01-04 01:25:12 -05:00
parent 6529de43d4
commit 95d594bdac
34 changed files with 358 additions and 48 deletions

View File

@@ -5,7 +5,7 @@ path: ./target/account-web-0.0.1-SNAPSHOT.jar
buildpack: java_buildpack
services:
- rabbit-events
- redis-cache
- discovery-service
disk_quota: 1024M
host: account-event-web
domain: cfapps.io

View File

@@ -31,10 +31,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
@@ -51,11 +47,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>

View File

@@ -8,9 +8,9 @@ import org.springframework.hateoas.config.EnableHypermediaSupport;
@SpringBootApplication
@EnableDiscoveryClient
@EnableHypermediaSupport(type = {EnableHypermediaSupport.HypermediaType.HAL})
public class AccountServiceApplication {
public class AccountWeb {
public static void main(String[] args) {
SpringApplication.run(AccountServiceApplication.class, args);
SpringApplication.run(AccountWeb.class, args);
}
}

View File

@@ -5,15 +5,19 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.Collections;
import java.util.List;
@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
private ObjectMapper objectMapper;
@@ -37,4 +41,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
converter.setObjectMapper(objectMapper);
return new RestTemplate(Collections.singletonList(converter));
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}
}

View File

@@ -4,8 +4,6 @@ spring:
---
spring:
profiles: development
jackson:
default-property-inclusion: non_null
cloud:
stream:
bindings:
@@ -31,4 +29,27 @@ events:
worker: http://account-worker/v1/events
eureka:
client:
enabled: false
enabled: false
---
spring:
profiles: cloud
cloud:
stream:
bindings:
output:
destination: account
contentType: 'application/json'
events:
worker: http://account-worker/v1/events
eureka:
instance:
hostname: ${vcap.application.uris[0]:localhost}
nonSecurePort: 80
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
leaseRenewalIntervalInSeconds: 5
client:
region: default
registryFetchIntervalSeconds: 5
serviceUrl:
defaultZone: ${vcap.services.discovery-service.credentials.uri:http://localhost:8761}/eureka/

View File

@@ -5,6 +5,7 @@ path: ./target/account-worker-0.0.1-SNAPSHOT.jar
buildpack: java_buildpack
services:
- rabbit-events
- discovery-service
disk_quota: 1024M
host: account-event-worker
domain: cfapps.io

View File

@@ -9,9 +9,9 @@ import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType
@SpringBootApplication
@EnableDiscoveryClient
@EnableHypermediaSupport(type = {HypermediaType.HAL})
public class OrderWorkerApplication {
public class AccountWorker {
public static void main(String[] args) {
SpringApplication.run(OrderWorkerApplication.class, args);
SpringApplication.run(AccountWorker.class, args);
}
}

View File

@@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Configuration
@Profile("cloud")
@Profile("lambda")
public class AwsLambdaConfig {
@Bean

View File

@@ -26,4 +26,32 @@ spring:
profiles: test
eureka:
client:
enabled: false
enabled: false
---
spring:
profiles: cloud
cloud:
stream:
bindings:
input:
destination: account
group: account-group
contentType: 'application/json'
consumer:
durableSubscription: true
amazon:
aws:
access-key-id: ${AMAZON_AWS_ACCESS_KEY_ID:replace}
access-key-secret: ${AMAZON_AWS_ACCESS_KEY_SECRET:replace}
eureka:
instance:
hostname: ${vcap.application.uris[0]:localhost}
nonSecurePort: 80
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
leaseRenewalIntervalInSeconds: 5
client:
region: default
registryFetchIntervalSeconds: 5
serviceUrl:
defaultZone: ${vcap.services.discovery-service.credentials.uri:http://localhost:8761}/eureka/

View File

@@ -0,0 +1,11 @@
name: order-web
memory: 1024M
instances: 1
path: ./target/order-web-0.0.1-SNAPSHOT.jar
buildpack: java_buildpack
services:
- rabbit-events
- discovery-service
disk_quota: 1024M
host: order-event-web
domain: cfapps.io

View File

@@ -31,10 +31,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>

View File

@@ -8,9 +8,9 @@ import org.springframework.hateoas.config.EnableHypermediaSupport;
@SpringBootApplication
@EnableDiscoveryClient
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
public class OrderWebApplication {
public class OrderWeb {
public static void main(String[] args) {
SpringApplication.run(OrderWebApplication.class, args);
SpringApplication.run(OrderWeb.class, args);
}
}

View File

@@ -5,15 +5,19 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.Collections;
import java.util.List;
@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
private ObjectMapper objectMapper;
@@ -37,4 +41,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
converter.setObjectMapper(objectMapper);
return new RestTemplate(Collections.singletonList(converter));
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}
}

View File

@@ -31,4 +31,27 @@ events:
worker: http://order-worker/v1/events
eureka:
client:
enabled: false
enabled: false
---
spring:
profiles: cloud
cloud:
stream:
bindings:
output:
destination: order
contentType: 'application/json'
events:
worker: http://order-worker/v1/events
eureka:
instance:
hostname: ${vcap.application.uris[0]:localhost}
nonSecurePort: 80
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
leaseRenewalIntervalInSeconds: 5
client:
region: default
registryFetchIntervalSeconds: 5
serviceUrl:
defaultZone: ${vcap.services.discovery-service.credentials.uri:http://localhost:8761}/eureka/

View File

@@ -0,0 +1,11 @@
name: order-worker
memory: 1024M
instances: 1
path: ./target/order-worker-0.0.1-SNAPSHOT.jar
buildpack: java_buildpack
services:
- rabbit-events
- discovery-service
disk_quota: 1024M
host: order-event-worker
domain: cfapps.io

View File

@@ -9,9 +9,9 @@ import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType
@SpringBootApplication
@EnableDiscoveryClient
@EnableHypermediaSupport(type = {HypermediaType.HAL})
public class PaymentStreamModuleApplication {
public class OrderWorker {
public static void main(String[] args) {
SpringApplication.run(PaymentStreamModuleApplication.class, args);
SpringApplication.run(OrderWorker.class, args);
}
}

View File

@@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Configuration
@Profile("cloud")
@Profile("lambda")
public class AwsLambdaConfig {
@Bean

View File

@@ -28,4 +28,34 @@ eureka:
client:
enabled: false
server:
port: 0
port: 0
---
spring:
profiles: cloud
cloud:
stream:
bindings:
input:
destination: order
group: order-group
contentType: 'application/json'
consumer:
durableSubscription: true
server:
port: 0
amazon:
aws:
access-key-id: replace
access-key-secret: replace
eureka:
instance:
hostname: ${vcap.application.uris[0]:localhost}
nonSecurePort: 80
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
leaseRenewalIntervalInSeconds: 5
client:
region: default
registryFetchIntervalSeconds: 5
serviceUrl:
defaultZone: ${vcap.services.discovery-service.credentials.uri:http://localhost:8761}/eureka/

View File

@@ -0,0 +1,11 @@
name: payment-web
memory: 1024M
instances: 1
path: ./target/payment-web-0.0.1-SNAPSHOT.jar
buildpack: java_buildpack
services:
- rabbit-events
- discovery-service
disk_quota: 1024M
host: payment-event-web
domain: cfapps.io

View File

@@ -31,10 +31,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>

View File

@@ -8,9 +8,9 @@ import org.springframework.hateoas.config.EnableHypermediaSupport;
@SpringBootApplication
@EnableDiscoveryClient
@EnableHypermediaSupport(type = {EnableHypermediaSupport.HypermediaType.HAL})
public class PaymentServiceApplication {
public class PaymentWeb {
public static void main(String[] args) {
SpringApplication.run(PaymentServiceApplication.class, args);
SpringApplication.run(PaymentWeb.class, args);
}
}

View File

@@ -5,15 +5,19 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.Collections;
import java.util.List;
@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
private ObjectMapper objectMapper;
@@ -37,4 +41,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
converter.setObjectMapper(objectMapper);
return new RestTemplate(Collections.singletonList(converter));
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}
}

View File

@@ -10,11 +10,6 @@ spring:
output:
destination: payment
contentType: 'application/json'
jackson:
default-property-inclusion: non_null
redis:
host: localhost
port: 6379
server:
port: 0
events:
@@ -34,4 +29,27 @@ events:
worker: http://payment-worker/v1/events
eureka:
client:
enabled: false
enabled: false
---
spring:
profiles: cloud
cloud:
stream:
bindings:
output:
destination: payment
contentType: 'application/json'
events:
worker: http://payment-worker/v1/events
eureka:
instance:
hostname: ${vcap.application.uris[0]:localhost}
nonSecurePort: 80
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
leaseRenewalIntervalInSeconds: 5
client:
region: default
registryFetchIntervalSeconds: 5
serviceUrl:
defaultZone: ${vcap.services.discovery-service.credentials.uri:http://localhost:8761}/eureka/

View File

@@ -0,0 +1,11 @@
name: payment-worker
memory: 1024M
instances: 1
path: ./target/payment-worker-0.0.1-SNAPSHOT.jar
buildpack: java_buildpack
services:
- rabbit-events
- discovery-service
disk_quota: 1024M
host: payment-event-worker
domain: cfapps.io

View File

@@ -9,9 +9,9 @@ import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType
@SpringBootApplication
@EnableDiscoveryClient
@EnableHypermediaSupport(type = {HypermediaType.HAL})
public class AccountStreamModuleApplication {
public class PaymentWorker {
public static void main(String[] args) {
SpringApplication.run(AccountStreamModuleApplication.class, args);
SpringApplication.run(PaymentWorker.class, args);
}
}

View File

@@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Configuration
@Profile("cloud")
@Profile("lambda")
public class AwsLambdaConfig {
@Bean

View File

@@ -13,8 +13,6 @@ spring:
contentType: 'application/json'
consumer:
durableSubscription: true
jackson:
default-property-inclusion: non_null
server:
port: 0
amazon:
@@ -26,4 +24,28 @@ spring:
profiles: test
eureka:
client:
enabled: false
enabled: false
---
spring:
profiles: cloud
cloud:
stream:
bindings:
input:
destination: payment
group: payment-group
contentType: 'application/json'
consumer:
durableSubscription: true
eureka:
instance:
hostname: ${vcap.application.uris[0]:localhost}
nonSecurePort: 80
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
leaseRenewalIntervalInSeconds: 5
client:
region: default
registryFetchIntervalSeconds: 5
serviceUrl:
defaultZone: ${vcap.services.discovery-service.credentials.uri:http://localhost:8761}/eureka/

View File

@@ -0,0 +1,8 @@
name: discovery-service
memory: 512M
instances: 1
path: ./target/discovery-1.0-SNAPSHOT.jar
buildpack: java_buildpack
disk_quota: 1024M
host: event-stream-discovery-service
domain: cfapps.io

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>discovery</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>org.kbastani</groupId>
<artifactId>platform-services</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,14 @@
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class DiscoveryServiceApplication {
public static void main(String[] args) {
SpringApplication.run(DiscoveryServiceApplication.class, args);
}
}

View File

@@ -0,0 +1,2 @@
server.port=8761
spring.application.name=discovery-service

View File

@@ -0,0 +1,16 @@
package com.example;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class DiscoveryServiceApplicationTests {
@Test
public void contextLoads() {
}
}

29
platform-services/pom.xml Normal file
View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>platform-services</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>platform-services</name>
<parent>
<groupId>org.kbastani</groupId>
<artifactId>event-stream-processing-microservices</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<modules>
<module>discovery</module>
</modules>
</project>

View File

@@ -26,6 +26,7 @@
</properties>
<modules>
<module>platform-services</module>
<module>spring-boot-starters</module>
<module>account</module>
<module>order</module>