Added docker build and compose file
This commit is contained in:
5
account/account-web/docker/Dockerfile
Normal file
5
account/account-web/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM anapsix/alpine-java:8
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD account-web-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
RUN bash -c 'touch /app.jar'
|
||||||
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||||
@@ -74,6 +74,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.4.13</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,42 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: development
|
active: development
|
||||||
|
cloud:
|
||||||
|
stream:
|
||||||
|
bindings:
|
||||||
|
output:
|
||||||
|
destination: account
|
||||||
|
contentType: 'application/json'
|
||||||
|
server:
|
||||||
|
port: 0
|
||||||
|
events:
|
||||||
|
worker: http://account-worker/v1/events
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: development
|
profiles: development
|
||||||
cloud:
|
---
|
||||||
stream:
|
spring:
|
||||||
bindings:
|
profiles: docker
|
||||||
output:
|
rabbitmq:
|
||||||
destination: account
|
host: ${DOCKER_IP:192.168.99.100}
|
||||||
contentType: 'application/json'
|
port: 5672
|
||||||
server:
|
eureka:
|
||||||
port: 0
|
client:
|
||||||
events:
|
service-url:
|
||||||
worker: http://account-worker/v1/events
|
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||||
|
registryFetchIntervalSeconds: 5
|
||||||
|
instance:
|
||||||
|
hostname: ${DOCKER_IP:192.168.99.100}
|
||||||
|
leaseRenewalIntervalInSeconds: 5
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: test
|
profiles: test
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
output:
|
|
||||||
destination: account
|
|
||||||
contentType: 'application/json'
|
|
||||||
server:
|
|
||||||
port: 0
|
|
||||||
events:
|
|
||||||
worker: http://account-worker/v1/events
|
|
||||||
eureka:
|
eureka:
|
||||||
client:
|
client:
|
||||||
enabled: false
|
enabled: false
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: cloud
|
profiles: cloud
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
output:
|
|
||||||
destination: account
|
|
||||||
contentType: 'application/json'
|
|
||||||
events:
|
|
||||||
worker: http://account-worker/v1/events
|
|
||||||
eureka:
|
eureka:
|
||||||
instance:
|
instance:
|
||||||
hostname: ${vcap.application.uris[0]:localhost}
|
hostname: ${vcap.application.uris[0]:localhost}
|
||||||
|
|||||||
5
account/account-worker/docker/Dockerfile
Normal file
5
account/account-worker/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM anapsix/alpine-java:8
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD account-worker-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
RUN bash -c 'touch /app.jar'
|
||||||
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||||
@@ -92,6 +92,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.4.13</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import org.springframework.statemachine.StateMachine;
|
|||||||
*/
|
*/
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@EnableBinding(Sink.class)
|
@EnableBinding(Sink.class)
|
||||||
@Profile({ "cloud", "development" })
|
@Profile({ "cloud", "development", "docker" })
|
||||||
public class AccountEventStream {
|
public class AccountEventStream {
|
||||||
|
|
||||||
private EventService eventService;
|
private EventService eventService;
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: development
|
active: development
|
||||||
---
|
|
||||||
spring:
|
|
||||||
profiles: development
|
|
||||||
cloud:
|
cloud:
|
||||||
stream:
|
stream:
|
||||||
bindings:
|
bindings:
|
||||||
@@ -13,8 +10,6 @@ spring:
|
|||||||
contentType: 'application/json'
|
contentType: 'application/json'
|
||||||
consumer:
|
consumer:
|
||||||
durableSubscription: true
|
durableSubscription: true
|
||||||
jackson:
|
|
||||||
default-property-inclusion: non_null
|
|
||||||
server:
|
server:
|
||||||
port: 0
|
port: 0
|
||||||
amazon:
|
amazon:
|
||||||
@@ -22,23 +17,31 @@ amazon:
|
|||||||
access-key-id: replace
|
access-key-id: replace
|
||||||
access-key-secret: replace
|
access-key-secret: replace
|
||||||
---
|
---
|
||||||
|
spring:
|
||||||
|
profiles: development
|
||||||
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: test
|
profiles: test
|
||||||
eureka:
|
eureka:
|
||||||
client:
|
client:
|
||||||
enabled: false
|
enabled: false
|
||||||
---
|
---
|
||||||
|
spring:
|
||||||
|
profiles: docker
|
||||||
|
rabbitmq:
|
||||||
|
host: ${DOCKER_IP:192.168.99.100}
|
||||||
|
port: 5672
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
service-url:
|
||||||
|
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||||
|
registryFetchIntervalSeconds: 5
|
||||||
|
instance:
|
||||||
|
hostname: ${DOCKER_IP:192.168.99.100}
|
||||||
|
leaseRenewalIntervalInSeconds: 5
|
||||||
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: cloud
|
profiles: cloud
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
input:
|
|
||||||
destination: account
|
|
||||||
group: account-group
|
|
||||||
contentType: 'application/json'
|
|
||||||
consumer:
|
|
||||||
durableSubscription: true
|
|
||||||
amazon:
|
amazon:
|
||||||
aws:
|
aws:
|
||||||
access-key-id: ${AMAZON_AWS_ACCESS_KEY_ID:replace}
|
access-key-id: ${AMAZON_AWS_ACCESS_KEY_ID:replace}
|
||||||
|
|||||||
68
docker-compose.yml
Normal file
68
docker-compose.yml
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
mysql:
|
||||||
|
image: mysql:latest
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=dbpass
|
||||||
|
- MYSQL_DATABASE=dev]
|
||||||
|
net: host
|
||||||
|
rabbit:
|
||||||
|
container_name: rabbit
|
||||||
|
image: rabbitmq:3-management
|
||||||
|
net: host
|
||||||
|
account-web:
|
||||||
|
image: account-web
|
||||||
|
environment:
|
||||||
|
- SPRING_PROFILES_ACTIVE=docker
|
||||||
|
- DOCKER_IP=$DOCKER_IP
|
||||||
|
net: host
|
||||||
|
account-worker:
|
||||||
|
image: account-worker
|
||||||
|
environment:
|
||||||
|
- SPRING_PROFILES_ACTIVE=docker
|
||||||
|
- DOCKER_IP=$DOCKER_IP
|
||||||
|
net: host
|
||||||
|
order-web:
|
||||||
|
image: order-web
|
||||||
|
environment:
|
||||||
|
- SPRING_PROFILES_ACTIVE=docker
|
||||||
|
- DOCKER_IP=$DOCKER_IP
|
||||||
|
net: host
|
||||||
|
order-worker:
|
||||||
|
image: order-worker
|
||||||
|
environment:
|
||||||
|
- SPRING_PROFILES_ACTIVE=docker
|
||||||
|
- DOCKER_IP=$DOCKER_IP
|
||||||
|
net: host
|
||||||
|
payment-web:
|
||||||
|
image: payment-web
|
||||||
|
environment:
|
||||||
|
- SPRING_PROFILES_ACTIVE=docker
|
||||||
|
- DOCKER_IP=$DOCKER_IP
|
||||||
|
net: host
|
||||||
|
payment-worker:
|
||||||
|
image: payment-worker
|
||||||
|
environment:
|
||||||
|
- SPRING_PROFILES_ACTIVE=docker
|
||||||
|
- DOCKER_IP=$DOCKER_IP
|
||||||
|
net: host
|
||||||
|
warehouse-web:
|
||||||
|
image: warehouse-web
|
||||||
|
environment:
|
||||||
|
- SPRING_PROFILES_ACTIVE=docker
|
||||||
|
- DOCKER_IP=$DOCKER_IP
|
||||||
|
net: host
|
||||||
|
warehouse-worker:
|
||||||
|
image: warehouse-worker
|
||||||
|
environment:
|
||||||
|
- SPRING_PROFILES_ACTIVE=docker
|
||||||
|
- DOCKER_IP=$DOCKER_IP
|
||||||
|
net: host
|
||||||
|
discovery:
|
||||||
|
image: discovery
|
||||||
|
ports:
|
||||||
|
- 8761:8761
|
||||||
|
environment:
|
||||||
|
- SPRING_PROFILES_ACTIVE=docker
|
||||||
|
- DOCKER_IP=$DOCKER_IP
|
||||||
|
net: host
|
||||||
5
order/order-web/docker/Dockerfile
Normal file
5
order/order-web/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM anapsix/alpine-java:8
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD order-web-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
RUN bash -c 'touch /app.jar'
|
||||||
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||||
@@ -74,6 +74,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.4.13</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ import java.util.List;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static demo.order.domain.OrderStatus.RESERVATION_FAILED;
|
||||||
|
import static demo.order.domain.OrderStatus.RESERVATION_SUCCEEDED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reserves inventory for an {@link Order}.
|
* Reserves inventory for an {@link Order}.
|
||||||
*
|
*
|
||||||
@@ -29,8 +32,13 @@ public class CompleteReservation extends Action<Order> {
|
|||||||
|
|
||||||
public Function<Order, Order> getFunction() {
|
public Function<Order, Order> getFunction() {
|
||||||
return (order) -> {
|
return (order) -> {
|
||||||
Assert.isTrue(order.getStatus() == OrderStatus.RESERVATION_PENDING,
|
if (order.getStatus() != RESERVATION_SUCCEEDED && order.getStatus() != RESERVATION_FAILED) {
|
||||||
"The order must be in a reservation pending state");
|
Assert.isTrue(order.getStatus() == OrderStatus.RESERVATION_PENDING,
|
||||||
|
"The order must be in a reservation pending state");
|
||||||
|
} else {
|
||||||
|
// Reservation has already completed
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
OrderService orderService = order.getModule(OrderModule.class).getDefaultService();
|
OrderService orderService = order.getModule(OrderModule.class).getDefaultService();
|
||||||
|
|
||||||
@@ -50,12 +58,12 @@ public class CompleteReservation extends Action<Order> {
|
|||||||
|
|
||||||
if (orderReserved && order.getStatus() == OrderStatus.RESERVATION_PENDING) {
|
if (orderReserved && order.getStatus() == OrderStatus.RESERVATION_PENDING) {
|
||||||
// Succeed the reservation and commit all inventory associated with order
|
// Succeed the reservation and commit all inventory associated with order
|
||||||
order.setStatus(OrderStatus.RESERVATION_SUCCEEDED);
|
order.setStatus(RESERVATION_SUCCEEDED);
|
||||||
order = orderService.update(order);
|
order = orderService.update(order);
|
||||||
order.sendAsyncEvent(new OrderEvent(OrderEventType.RESERVATION_SUCCEEDED, order));
|
order.sendAsyncEvent(new OrderEvent(OrderEventType.RESERVATION_SUCCEEDED, order));
|
||||||
} else if (reservationFailed && order.getStatus() == OrderStatus.RESERVATION_PENDING) {
|
} else if (reservationFailed && order.getStatus() == OrderStatus.RESERVATION_PENDING) {
|
||||||
// Fail the reservation and release all inventory associated with order
|
// Fail the reservation and release all inventory associated with order
|
||||||
order.setStatus(OrderStatus.RESERVATION_FAILED);
|
order.setStatus(RESERVATION_FAILED);
|
||||||
order = orderService.update(order);
|
order = orderService.update(order);
|
||||||
order.sendAsyncEvent(new OrderEvent(OrderEventType.RESERVATION_FAILED, order));
|
order.sendAsyncEvent(new OrderEvent(OrderEventType.RESERVATION_FAILED, order));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +1,42 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: development
|
active: development
|
||||||
---
|
|
||||||
spring:
|
|
||||||
profiles: development
|
|
||||||
cloud:
|
cloud:
|
||||||
stream:
|
stream:
|
||||||
bindings:
|
bindings:
|
||||||
output:
|
output:
|
||||||
destination: order
|
destination: order
|
||||||
contentType: 'application/json'
|
contentType: 'application/json'
|
||||||
jackson:
|
|
||||||
default-property-inclusion: non_null
|
|
||||||
server:
|
server:
|
||||||
port: 0
|
port: 0
|
||||||
events:
|
events:
|
||||||
worker: http://order-worker/v1/events
|
worker: http://order-worker/v1/events
|
||||||
---
|
---
|
||||||
|
spring:
|
||||||
|
profiles: development
|
||||||
|
---
|
||||||
|
spring:
|
||||||
|
profiles: docker
|
||||||
|
rabbitmq:
|
||||||
|
host: ${DOCKER_IP:192.168.99.100}
|
||||||
|
port: 5672
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
service-url:
|
||||||
|
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||||
|
registryFetchIntervalSeconds: 5
|
||||||
|
instance:
|
||||||
|
hostname: ${DOCKER_IP:192.168.99.100}
|
||||||
|
leaseRenewalIntervalInSeconds: 5
|
||||||
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: test
|
profiles: test
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
output:
|
|
||||||
destination: order
|
|
||||||
contentType: 'application/json'
|
|
||||||
server:
|
|
||||||
port: 0
|
|
||||||
events:
|
|
||||||
worker: http://order-worker/v1/events
|
|
||||||
eureka:
|
eureka:
|
||||||
client:
|
client:
|
||||||
enabled: false
|
enabled: false
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: cloud
|
profiles: cloud
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
output:
|
|
||||||
destination: order
|
|
||||||
contentType: 'application/json'
|
|
||||||
events:
|
|
||||||
worker: http://order-worker/v1/events
|
|
||||||
eureka:
|
eureka:
|
||||||
instance:
|
instance:
|
||||||
hostname: ${vcap.application.uris[0]:localhost}
|
hostname: ${vcap.application.uris[0]:localhost}
|
||||||
|
|||||||
5
order/order-worker/docker/Dockerfile
Normal file
5
order/order-worker/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM anapsix/alpine-java:8
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD order-worker-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
RUN bash -c 'touch /app.jar'
|
||||||
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||||
@@ -92,6 +92,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.4.13</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import org.springframework.context.annotation.Profile;
|
|||||||
*/
|
*/
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@EnableBinding(Sink.class)
|
@EnableBinding(Sink.class)
|
||||||
@Profile({"cloud", "development"})
|
@Profile({"cloud", "development", "docker"})
|
||||||
public class OrderEventProcessor {
|
public class OrderEventProcessor {
|
||||||
|
|
||||||
private StateFactory stateFactory;
|
private StateFactory stateFactory;
|
||||||
|
|||||||
@@ -1,20 +1,15 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: development
|
active: development
|
||||||
---
|
|
||||||
spring:
|
|
||||||
profiles: development
|
|
||||||
cloud:
|
cloud:
|
||||||
stream:
|
stream:
|
||||||
bindings:
|
bindings:
|
||||||
input:
|
input:
|
||||||
|
contentType: 'application/json'
|
||||||
destination: order
|
destination: order
|
||||||
group: order-group
|
group: order-group
|
||||||
contentType: 'application/json'
|
|
||||||
consumer:
|
consumer:
|
||||||
durableSubscription: true
|
durableSubscription: true
|
||||||
jackson:
|
|
||||||
default-property-inclusion: non_null
|
|
||||||
server:
|
server:
|
||||||
port: 0
|
port: 0
|
||||||
amazon:
|
amazon:
|
||||||
@@ -22,31 +17,35 @@ amazon:
|
|||||||
access-key-id: replace
|
access-key-id: replace
|
||||||
access-key-secret: replace
|
access-key-secret: replace
|
||||||
---
|
---
|
||||||
|
spring:
|
||||||
|
profiles: development
|
||||||
|
---
|
||||||
|
spring:
|
||||||
|
profiles: docker
|
||||||
|
rabbitmq:
|
||||||
|
host: ${DOCKER_IP:192.168.99.100}
|
||||||
|
port: 5672
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
service-url:
|
||||||
|
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||||
|
registryFetchIntervalSeconds: 5
|
||||||
|
instance:
|
||||||
|
hostname: ${DOCKER_IP:192.168.99.100}
|
||||||
|
leaseRenewalIntervalInSeconds: 5
|
||||||
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: test
|
profiles: test
|
||||||
eureka:
|
eureka:
|
||||||
client:
|
client:
|
||||||
enabled: false
|
enabled: false
|
||||||
server:
|
|
||||||
port: 0
|
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: cloud
|
profiles: cloud
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
input:
|
|
||||||
destination: order
|
|
||||||
group: order-group
|
|
||||||
contentType: 'application/json'
|
|
||||||
consumer:
|
|
||||||
durableSubscription: true
|
|
||||||
server:
|
|
||||||
port: 0
|
|
||||||
amazon:
|
amazon:
|
||||||
aws:
|
aws:
|
||||||
access-key-id: replace
|
access-key-id: ${AMAZON_AWS_ACCESS_KEY_ID:replace}
|
||||||
access-key-secret: replace
|
access-key-secret: ${AMAZON_AWS_ACCESS_KEY_SECRET:replace}
|
||||||
eureka:
|
eureka:
|
||||||
instance:
|
instance:
|
||||||
hostname: ${vcap.application.uris[0]:localhost}
|
hostname: ${vcap.application.uris[0]:localhost}
|
||||||
|
|||||||
5
payment/payment-web/docker/Dockerfile
Normal file
5
payment/payment-web/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM anapsix/alpine-java:8
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD payment-web-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
RUN bash -c 'touch /app.jar'
|
||||||
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||||
@@ -73,6 +73,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.4.13</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,42 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: development
|
active: development
|
||||||
|
cloud:
|
||||||
|
stream:
|
||||||
|
bindings:
|
||||||
|
output:
|
||||||
|
contentType: 'application/json'
|
||||||
|
destination: payment
|
||||||
|
server:
|
||||||
|
port: 0
|
||||||
|
events:
|
||||||
|
worker: http://payment-worker/v1/events
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: development
|
profiles: development
|
||||||
cloud:
|
---
|
||||||
stream:
|
spring:
|
||||||
bindings:
|
profiles: docker
|
||||||
output:
|
rabbitmq:
|
||||||
destination: payment
|
host: ${DOCKER_IP:192.168.99.100}
|
||||||
contentType: 'application/json'
|
port: 5672
|
||||||
server:
|
eureka:
|
||||||
port: 0
|
client:
|
||||||
events:
|
service-url:
|
||||||
worker: http://payment-worker/v1/events
|
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||||
|
registryFetchIntervalSeconds: 5
|
||||||
|
instance:
|
||||||
|
hostname: ${DOCKER_IP:192.168.99.100}
|
||||||
|
leaseRenewalIntervalInSeconds: 5
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: test
|
profiles: test
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
output:
|
|
||||||
destination: payment
|
|
||||||
contentType: 'application/json'
|
|
||||||
server:
|
|
||||||
port: 0
|
|
||||||
events:
|
|
||||||
worker: http://payment-worker/v1/events
|
|
||||||
eureka:
|
eureka:
|
||||||
client:
|
client:
|
||||||
enabled: false
|
enabled: false
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: cloud
|
profiles: cloud
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
output:
|
|
||||||
destination: payment
|
|
||||||
contentType: 'application/json'
|
|
||||||
events:
|
|
||||||
worker: http://payment-worker/v1/events
|
|
||||||
eureka:
|
eureka:
|
||||||
instance:
|
instance:
|
||||||
hostname: ${vcap.application.uris[0]:localhost}
|
hostname: ${vcap.application.uris[0]:localhost}
|
||||||
|
|||||||
5
payment/payment-worker/docker/Dockerfile
Normal file
5
payment/payment-worker/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM anapsix/alpine-java:8
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD payment-worker-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
RUN bash -c 'touch /app.jar'
|
||||||
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||||
@@ -92,6 +92,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.4.13</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import org.springframework.statemachine.StateMachine;
|
|||||||
*/
|
*/
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@EnableBinding(Sink.class)
|
@EnableBinding(Sink.class)
|
||||||
@Profile({ "cloud", "development" })
|
@Profile({ "cloud", "development", "docker" })
|
||||||
public class PaymentEventStream {
|
public class PaymentEventStream {
|
||||||
|
|
||||||
private EventService eventService;
|
private EventService eventService;
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: development
|
active: development
|
||||||
---
|
|
||||||
spring:
|
|
||||||
profiles: development
|
|
||||||
cloud:
|
cloud:
|
||||||
stream:
|
stream:
|
||||||
bindings:
|
bindings:
|
||||||
input:
|
input:
|
||||||
|
contentType: 'application/json'
|
||||||
destination: payment
|
destination: payment
|
||||||
group: payment-group
|
group: payment-group
|
||||||
contentType: 'application/json'
|
|
||||||
consumer:
|
consumer:
|
||||||
durableSubscription: true
|
durableSubscription: true
|
||||||
server:
|
server:
|
||||||
@@ -20,6 +17,23 @@ amazon:
|
|||||||
access-key-id: replace
|
access-key-id: replace
|
||||||
access-key-secret: replace
|
access-key-secret: replace
|
||||||
---
|
---
|
||||||
|
spring:
|
||||||
|
profiles: development
|
||||||
|
---
|
||||||
|
spring:
|
||||||
|
profiles: docker
|
||||||
|
rabbitmq:
|
||||||
|
host: ${DOCKER_IP:192.168.99.100}
|
||||||
|
port: 5672
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
service-url:
|
||||||
|
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||||
|
registryFetchIntervalSeconds: 5
|
||||||
|
instance:
|
||||||
|
hostname: ${DOCKER_IP:192.168.99.100}
|
||||||
|
leaseRenewalIntervalInSeconds: 5
|
||||||
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: test
|
profiles: test
|
||||||
eureka:
|
eureka:
|
||||||
@@ -28,15 +42,6 @@ eureka:
|
|||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: cloud
|
profiles: cloud
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
input:
|
|
||||||
destination: payment
|
|
||||||
group: payment-group
|
|
||||||
contentType: 'application/json'
|
|
||||||
consumer:
|
|
||||||
durableSubscription: true
|
|
||||||
eureka:
|
eureka:
|
||||||
instance:
|
instance:
|
||||||
hostname: ${vcap.application.uris[0]:localhost}
|
hostname: ${vcap.application.uris[0]:localhost}
|
||||||
|
|||||||
5
platform-services/discovery/docker/Dockerfile
Normal file
5
platform-services/discovery/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM anapsix/alpine-java:8
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD discovery-1.0-SNAPSHOT.jar app.jar
|
||||||
|
RUN bash -c 'touch /app.jar'
|
||||||
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||||
@@ -31,6 +31,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.4.13</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
server.port=8761
|
|
||||||
spring.application.name=discovery-service
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
server:
|
||||||
|
port: ${PORT:8761}
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: discovery-service
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
registerWithEureka: false
|
||||||
|
fetchRegistry: false
|
||||||
|
server:
|
||||||
|
waitTimeInMsWhenSyncEmpty: 0
|
||||||
5
warehouse/warehouse-web/docker/Dockerfile
Normal file
5
warehouse/warehouse-web/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM anapsix/alpine-java:8
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD warehouse-web-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
RUN bash -c 'touch /app.jar'
|
||||||
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||||
@@ -74,6 +74,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.4.13</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package demo.inventory.action;
|
|
||||||
|
|
||||||
import demo.domain.Action;
|
|
||||||
import demo.inventory.domain.Inventory;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reserves inventory for an {@link Inventory}.
|
|
||||||
*
|
|
||||||
* @author Kenny Bastani
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class AddInventory extends Action<Inventory> {
|
|
||||||
public BiConsumer<Inventory, Long> getConsumer() {
|
|
||||||
return (inventory, warehouseId) -> {
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reserves inventory for an {@link Inventory}.
|
* Updates the status of a {@link Inventory} entity.
|
||||||
*
|
*
|
||||||
* @author Kenny Bastani
|
* @author Kenny Bastani
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,52 +1,48 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: development
|
active: development
|
||||||
---
|
|
||||||
spring:
|
|
||||||
profiles: development
|
|
||||||
cloud:
|
cloud:
|
||||||
stream:
|
stream:
|
||||||
bindings:
|
bindings:
|
||||||
warehouse:
|
warehouse:
|
||||||
|
contentType: 'application/json'
|
||||||
destination: warehouse
|
destination: warehouse
|
||||||
contentType: 'application/json'
|
|
||||||
reservation:
|
reservation:
|
||||||
|
contentType: 'application/json'
|
||||||
destination: reservation
|
destination: reservation
|
||||||
contentType: 'application/json'
|
|
||||||
inventory:
|
inventory:
|
||||||
destination: inventory
|
|
||||||
contentType: 'application/json'
|
contentType: 'application/json'
|
||||||
|
destination: inventory
|
||||||
server:
|
server:
|
||||||
port: 0
|
port: 0
|
||||||
events:
|
events:
|
||||||
worker: http://warehouse-worker/v1/events
|
worker: http://warehouse-worker/v1/events
|
||||||
---
|
---
|
||||||
|
spring:
|
||||||
|
profiles: development
|
||||||
|
---
|
||||||
|
spring:
|
||||||
|
profiles: docker
|
||||||
|
rabbitmq:
|
||||||
|
host: ${DOCKER_IP:192.168.99.100}
|
||||||
|
port: 5672
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
service-url:
|
||||||
|
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||||
|
registryFetchIntervalSeconds: 5
|
||||||
|
instance:
|
||||||
|
hostname: ${DOCKER_IP:192.168.99.100}
|
||||||
|
leaseRenewalIntervalInSeconds: 5
|
||||||
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: test
|
profiles: test
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
output:
|
|
||||||
destination: warehouse
|
|
||||||
contentType: 'application/json'
|
|
||||||
server:
|
|
||||||
port: 0
|
|
||||||
events:
|
|
||||||
worker: http://warehouse-worker/v1/events
|
|
||||||
eureka:
|
eureka:
|
||||||
client:
|
client:
|
||||||
enabled: false
|
enabled: false
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: cloud
|
profiles: cloud
|
||||||
cloud:
|
|
||||||
stream:
|
|
||||||
bindings:
|
|
||||||
output:
|
|
||||||
destination: warehouse
|
|
||||||
contentType: 'application/json'
|
|
||||||
events:
|
|
||||||
worker: http://warehouse-worker/v1/events
|
|
||||||
eureka:
|
eureka:
|
||||||
instance:
|
instance:
|
||||||
hostname: ${vcap.application.uris[0]:localhost}
|
hostname: ${vcap.application.uris[0]:localhost}
|
||||||
|
|||||||
5
warehouse/warehouse-worker/docker/Dockerfile
Normal file
5
warehouse/warehouse-worker/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM anapsix/alpine-java:8
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD warehouse-worker-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
RUN bash -c 'touch /app.jar'
|
||||||
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||||
@@ -92,6 +92,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.4.13</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Profile;
|
|||||||
*/
|
*/
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@EnableBinding(InventoryEventSink.class)
|
@EnableBinding(InventoryEventSink.class)
|
||||||
@Profile({"cloud", "development"})
|
@Profile({"cloud", "development", "docker"})
|
||||||
public class InventoryEventProcessor {
|
public class InventoryEventProcessor {
|
||||||
|
|
||||||
private InventoryStateFactory stateFactory;
|
private InventoryStateFactory stateFactory;
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import java.util.EnumSet;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static demo.order.domain.OrderStatus.RESERVATION_PENDING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A configuration adapter for describing a {@link StateMachine} factory that maps actions to functional
|
* A configuration adapter for describing a {@link StateMachine} factory that maps actions to functional
|
||||||
* expressions. Actions are executed during transitions between a source state and a target state.
|
* expressions. Actions are executed during transitions between a source state and a target state.
|
||||||
@@ -75,7 +77,7 @@ public class ReservationStateMachineConfig extends EnumStateMachineConfigurerAda
|
|||||||
*/
|
*/
|
||||||
private ReservationEvent applyEvent(StateContext<ReservationStatus, ReservationEventType> context,
|
private ReservationEvent applyEvent(StateContext<ReservationStatus, ReservationEventType> context,
|
||||||
ReservationFunction
|
ReservationFunction
|
||||||
reservationFunction) {
|
reservationFunction) {
|
||||||
ReservationEvent event = null;
|
ReservationEvent event = null;
|
||||||
log.info(String.format("Replicate event: %s", context.getMessage().getPayload()));
|
log.info(String.format("Replicate event: %s", context.getMessage().getPayload()));
|
||||||
|
|
||||||
@@ -261,8 +263,14 @@ public class ReservationStateMachineConfig extends EnumStateMachineConfigurerAda
|
|||||||
MediaTypes.HAL_JSON
|
MediaTypes.HAL_JSON
|
||||||
);
|
);
|
||||||
|
|
||||||
traverson.follow("self", "order", "commands", "completeReservation")
|
// Get the attached order
|
||||||
.toObject(Order.class);
|
Order order = traverson.follow("self", "order").toObject(Order.class);
|
||||||
|
|
||||||
|
// Complete the reservation if the status is still pending
|
||||||
|
if (order.getStatus() == RESERVATION_PENDING) {
|
||||||
|
traverson.follow("self", "order", "commands", "completeReservation")
|
||||||
|
.toObject(Order.class);
|
||||||
|
}
|
||||||
|
|
||||||
return traverson.follow("self")
|
return traverson.follow("self")
|
||||||
.toEntity(Reservation.class)
|
.toEntity(Reservation.class)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Profile;
|
|||||||
*/
|
*/
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@EnableBinding(ReservationEventSink.class)
|
@EnableBinding(ReservationEventSink.class)
|
||||||
@Profile({"cloud", "development"})
|
@Profile({"cloud", "development", "docker"})
|
||||||
public class ReservationEventProcessor {
|
public class ReservationEventProcessor {
|
||||||
|
|
||||||
private ReservationStateFactory stateFactory;
|
private ReservationStateFactory stateFactory;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Profile;
|
|||||||
*/
|
*/
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@EnableBinding(WarehouseEventSink.class)
|
@EnableBinding(WarehouseEventSink.class)
|
||||||
@Profile({"cloud", "development"})
|
@Profile({"cloud", "development", "docker"})
|
||||||
public class WarehouseEventProcessor {
|
public class WarehouseEventProcessor {
|
||||||
|
|
||||||
private WarehouseStateFactory stateFactory;
|
private WarehouseStateFactory stateFactory;
|
||||||
|
|||||||
@@ -5,41 +5,51 @@ spring:
|
|||||||
stream:
|
stream:
|
||||||
bindings:
|
bindings:
|
||||||
warehouse:
|
warehouse:
|
||||||
|
contentType: 'application/json'
|
||||||
destination: warehouse
|
destination: warehouse
|
||||||
group: warehouse-group
|
group: warehouse-group
|
||||||
contentType: 'application/json'
|
|
||||||
consumer:
|
consumer:
|
||||||
durableSubscription: true
|
durableSubscription: true
|
||||||
reservation:
|
reservation:
|
||||||
|
contentType: 'application/json'
|
||||||
destination: reservation
|
destination: reservation
|
||||||
group: reservation-group
|
group: reservation-group
|
||||||
contentType: 'application/json'
|
|
||||||
consumer:
|
consumer:
|
||||||
durableSubscription: true
|
durableSubscription: true
|
||||||
inventory:
|
inventory:
|
||||||
|
contentType: 'application/json'
|
||||||
destination: inventory
|
destination: inventory
|
||||||
group: inventory-group
|
group: inventory-group
|
||||||
contentType: 'application/json'
|
|
||||||
consumer:
|
consumer:
|
||||||
durableSubscription: true
|
durableSubscription: true
|
||||||
|
server:
|
||||||
|
port: 0
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: development
|
profiles: development
|
||||||
server:
|
---
|
||||||
port: 0
|
spring:
|
||||||
|
profiles: docker
|
||||||
|
rabbitmq:
|
||||||
|
host: ${DOCKER_IP:192.168.99.100}
|
||||||
|
port: 5672
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
service-url:
|
||||||
|
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||||
|
registryFetchIntervalSeconds: 5
|
||||||
|
instance:
|
||||||
|
hostname: ${DOCKER_IP:192.168.99.100}
|
||||||
|
leaseRenewalIntervalInSeconds: 5
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: test
|
profiles: test
|
||||||
eureka:
|
eureka:
|
||||||
client:
|
client:
|
||||||
enabled: false
|
enabled: false
|
||||||
server:
|
|
||||||
port: 0
|
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: cloud
|
profiles: cloud
|
||||||
server:
|
|
||||||
port: 0
|
|
||||||
eureka:
|
eureka:
|
||||||
instance:
|
instance:
|
||||||
hostname: ${vcap.application.uris[0]:localhost}
|
hostname: ${vcap.application.uris[0]:localhost}
|
||||||
|
|||||||
Reference in New Issue
Block a user