Skip to content

Commit e9bb6dd

Browse files
committed
Upgraded to the latest version of Eventuate + Spring Boot 2.6, etc
1 parent 6f76d2f commit e9bb6dd

File tree

161 files changed

+268
-2717
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+268
-2717
lines changed

.circleci/config.yml

+6-12
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,20 @@ jobs:
1616
steps:
1717
- checkout
1818

19-
# Download and cache dependencies
2019
- restore_cache:
2120
keys:
22-
- eventuate-examples-java-spring-todo-list-{{ checksum "single-module/gradle.properties" }}
23-
# fallback to using the latest cache if no exact match is found
21+
- eventuate-examples-java-spring-todo-list-{{ checksum "single-module/gradle.properties" }}-{{ checksum "single-module/gradle/wrapper/gradle-wrapper.properties" }}
2422
- eventuate-examples-java-spring-todo-list-
2523

26-
- run: cd single-module && ./gradlew dependencies
27-
- run: cd multi-module && ./gradlew dependencies
24+
- run: ./gradlew testClasses
2825

2926
- save_cache:
3027
paths:
3128
- ~/.m2
3229
- ~/.gradle
33-
key: eventuate-examples-java-spring-todo-list-{{ checksum "single-module/gradle.properties" }}
30+
key: eventuate-examples-java-spring-todo-list-{{ checksum "single-module/gradle.properties" }}-{{ checksum "single-module/gradle/wrapper/gradle-wrapper.properties" }}
3431

3532
# run tests!
36-
- run: cd single-module && ./build-and-test-all-eventuate-local-mysql.sh
37-
- run: cd single-module && ./build-and-test-all-eventuate-local-postgres-polling.sh
38-
- run: cd single-module && ./build-and-test-all-eventuate-local-postgres-wal.sh
39-
- run: cd multi-module && ./build-and-test-all-eventuate-local-mysql.sh
40-
- run: cd multi-module && ./build-and-test-all-eventuate-local-postgres-polling.sh
41-
- run: cd multi-module && ./build-and-test-all-eventuate-local-postgres-wal.sh
33+
- run: ./build-and-test-all-mysql.sh
34+
- run: ./build-and-test-all-postgres-polling.sh
35+
- run: ./build-and-test-all-postgres-wal.sh

README.md

+2-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Todo List example application
22

3-
The Todo List application is the hello world application for the [Eventuate™ Platform](http://eventuate.io).
3+
The Todo List application is the hello world application for the [Eventuate™ event sourcing](http://eventuate.io).
44
It illustrates how you can use the platform to write an application with a [microservices architecture](http://microservices.io/patterns/microservices.html) that uses [Event Sourcing](http://microservices.io/patterns/data/event-sourcing.html) and [Command Query Responsibility Segregation (CQRS)](http://microservices.io/patterns/data/cqrs.html).
55
The Todo List application lets users maintain a todo list.
66

@@ -39,27 +39,13 @@ MySQL is kept up to date by subscribing to events produced by the Todo service.
3939

4040
Note: for simplicity, the Todo list application can be deployed as a monolithic application.
4141

42-
# Two versions of the source code
43-
44-
There are two versions of the source code:
45-
46-
* `single-module` - a single module Gradle project for a monolithic version of the application.
47-
It is the easiest to get started with.
48-
* `multi-module` - a multi-module Gradle project for the microservices-based version of the application.
49-
50-
Note: you do not need to install Gradle since it will be downloaded automatically.
51-
You just need to have Java 8 installed.
5242

5343
# Building and running the application
5444

55-
The steps for building both versions of the application are identical.
56-
57-
## Building and running using Eventuate Local
58-
5945
First, build the application
6046

6147
```
62-
./gradlew assemble -P eventuateDriver=local
48+
./gradlew assemble
6349
```
6450

6551
Next, launch the services using [Docker Compose](https://docs.docker.com/compose/):
@@ -85,20 +71,9 @@ See this [guide to setting `DOCKER_HOST_IP`](http://eventuate.io/docs/usingdocke
8571

8672
Once the application has started, you can use the application via the Swagger UI.
8773

88-
If you are running the `multi-module` version:
89-
9074
* `http://${DOCKER_HOST_IP}:8081/swagger-ui.html` - the command-side service
9175
* `http://${DOCKER_HOST_IP}:8082/swagger-ui.html` - the query-side service
9276

93-
If you are running the `single-module` version:
94-
95-
* `http://${DOCKER_HOST_IP}:8080/swagger-ui.html` - the monolithic application
96-
97-
# Using the Eventuate Local console
98-
99-
You can also use the Eventuate Local console to view aggregates and watch the stream of events.
100-
Visit the URL `http://${DOCKER_HOST_IP}:8085`
101-
10277
# Got questions?
10378

10479
Don't hesitate to create an issue or see

multi-module/_build-and-test-all.sh _build-and-test-all.sh

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -e
44

5+
./gradlew $BUILD_AND_TEST_ALL_EXTRA_GRADLE_ARGS testClasses
6+
57
if [ -z "$DOCKER_HOST_IP" ] ; then
68
if [ -z "$DOCKER_HOST" ] ; then
79
export DOCKER_HOST_IP=`hostname`
@@ -27,6 +29,7 @@ if [ "$1" = "--no-rm" ] ; then
2729
shift
2830
fi
2931

32+
3033
if [ ! -z "$EXTRA_INFRASTRUCTURE_SERVICES" ]; then
3134
./gradlew ${EXTRA_INFRASTRUCTURE_SERVICES}ComposeBuild
3235
./gradlew ${EXTRA_INFRASTRUCTURE_SERVICES}ComposeUp
File renamed without changes.

build-and-test-everything.sh

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
set -e
44
set -o pipefail
55

6-
SCRIPTS="single-module/build-and-test-all-eventuate-local-mysql.sh
7-
single-module/build-and-test-all-eventuate-local-postgres-polling.sh
8-
single-module/build-and-test-all-eventuate-local-postgres-wal.sh
9-
multi-module/build-and-test-all-eventuate-local-mysql.sh
10-
multi-module/build-and-test-all-eventuate-local-postgres-polling.sh
11-
multi-module/build-and-test-all-eventuate-local-postgres-wal.sh
6+
SCRIPTS="build-and-test-all-mysql.sh
7+
build-and-test-all-postgres-polling.sh
8+
build-and-test-all-postgres-wal.sh
129
"
1310

1411
date > build-and-test-everything.log

multi-module/build.gradle build.gradle

+14-8
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,38 @@ buildscript {
55
}
66
dependencies {
77
classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
8-
classpath "com.avast.gradle:gradle-docker-compose-plugin:0.9.2"
8+
classpath "com.avast.gradle:gradle-docker-compose-plugin:$dockerComposePluginVersion"
99
}
1010
}
1111

1212
apply plugin: 'docker-compose'
1313

14-
task wrapper(type: Wrapper) {
15-
gradleVersion = '3.5'
16-
}
17-
1814
subprojects {
1915
apply plugin: 'java'
2016
sourceCompatibility = 1.8
2117
targetCompatibility = 1.8
2218

2319
repositories {
2420
mavenCentral()
25-
jcenter()
2621
eventuateMavenRepoUrl.split(',').each { repoUrl -> maven { url repoUrl } }
2722
}
23+
24+
dependencies {
25+
implementation(platform("io.eventuate.platform:eventuate-platform-dependencies:$eventuatePlatformVersion"))
26+
implementation(platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion"))
27+
constraints {
28+
implementation "org.springdoc:springdoc-openapi-ui:$springDocOpenApiUiVersion"
29+
}
30+
}
31+
2832
}
2933

3034
dockerCompose {
3135
environment.put "EVENTUATE_COMMON_VERSION", eventuateCommonImageVersion
32-
environment.put "EVENTUATE_KAFKA_VERSION", eventuateMessagingKafkaImageVersion
36+
environment.put "EVENTUATE_MESSAGING_KAFKA_IMAGE_VERSION", eventuateMessagingKafkaImageVersion
3337
environment.put "EVENTUATE_CDC_VERSION", eventuateCdcImageVersion
38+
environment.put "EVENTUATE_MESSAGING_KAFKA_IMAGE_VERSION", eventuateMessagingKafkaImageVersion
39+
environment.put "EVENTUATE_JAVA_BASE_IMAGE_VERSION", eventuateExamplesBaseImageVersion
3440

3541
mysqlbinlog {
3642
projectName = null
@@ -64,4 +70,4 @@ dockerCompose {
6470
useComposeFiles = ["docker-compose-eventuate-local-postgres-wal.yml"]
6571
startedServices = ["cdcservice"]
6672
}
67-
}
73+
}

common-hateoas/build.gradle

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apply plugin: 'java'
2+
3+
dependencies {
4+
compile project(":common")
5+
6+
compile "io.eventuate.local.java:eventuate-client-java-spring"
7+
8+
compile("org.springframework.boot:spring-boot-starter-data-jpa")
9+
compile("org.springframework.boot:spring-boot-starter-web")
10+
compile "org.springframework.boot:spring-boot-starter-actuator"
11+
compile("org.springframework.hateoas:spring-hateoas")
12+
13+
testCompile 'junit:junit:4.12'
14+
}
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44
import net.chrisrichardson.eventstore.examples.todolist.common.model.ResourceWithUrl;
55
import net.chrisrichardson.eventstore.examples.todolist.model.Todo;
66
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.http.ResponseEntity;
78
import org.springframework.web.bind.annotation.PathVariable;
89
import org.springframework.web.bind.annotation.RequestMapping;
910
import org.springframework.web.bind.annotation.RestController;
1011

11-
import java.util.concurrent.CompletableFuture;
12-
13-
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
14-
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
12+
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
13+
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
1514
import static org.springframework.web.bind.annotation.RequestMethod.GET;
1615

17-
/**
18-
* Created by popikyardo on 23.03.16.
19-
*/
2016
@RestController
2117
@RequestMapping(value = "/todos")
2218
public class TodoHateoasController extends BaseController {
@@ -25,8 +21,10 @@ public class TodoHateoasController extends BaseController {
2521
private TodoUpdateService queryService;
2622

2723
@RequestMapping(value = "/{todo-id}", method = GET)
28-
public CompletableFuture<ResourceWithUrl> getTodo(@PathVariable("todo-id") String id) {
29-
return queryService.findById(id).thenApply(this::toResource);
24+
public ResponseEntity<ResourceWithUrl> getTodo(@PathVariable("todo-id") String id) {
25+
return queryService.findById(id)
26+
.map(todo -> ResponseEntity.ok(toResource(todo)))
27+
.orElseGet(() -> ResponseEntity.notFound().build());
3028
}
3129

3230
public ResourceWithUrl toResource(Todo todo) {
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
import net.chrisrichardson.eventstore.examples.todolist.model.Todo;
44

55
import java.util.List;
6-
import java.util.concurrent.CompletableFuture;
6+
import java.util.Optional;
7+
78

8-
/**
9-
* Created by popikyardo on 23.03.16.
10-
*/
119
public interface TodoUpdateService {
1210

1311
List<Todo> getAll();
1412

15-
CompletableFuture<Todo> findById(String todoId);
13+
Optional<Todo> findById(String todoId);
1614
}

common/build.gradle

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apply plugin: 'java'
2+
3+
dependencies {
4+
compile "io.eventuate.local.java:eventuate-client-java-spring"
5+
compile "org.springframework.boot:spring-boot-starter-web"
6+
compile("org.springframework.boot:spring-boot-starter-data-jpa")
7+
8+
compile 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3'
9+
compile 'com.sun.xml.bind:jaxb-impl:2.3.3'
10+
11+
testCompile 'junit:junit:4.12'
12+
}

multi-module/docker-compose-eventuate-local-mysql.yml docker-compose-eventuate-local-mysql.yml

+24-32
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ services:
77

88

99
kafka:
10-
image: eventuateio/eventuate-kafka:$EVENTUATE_KAFKA_VERSION
10+
image: "eventuateio/eventuate-kafka:${EVENTUATE_MESSAGING_KAFKA_IMAGE_VERSION?}"
1111
ports:
1212
- 9092:9092
13+
- 29092:29092
1314
depends_on:
1415
- zookeeper
1516
environment:
16-
- ADVERTISED_HOST_NAME=${DOCKER_HOST_IP}
17-
- KAFKA_HEAP_OPTS=-Xmx320m -Xms320m
18-
- ZOOKEEPER_SERVERS=zookeeper:2181
17+
KAFKA_LISTENERS: LC://kafka:29092,LX://kafka:9092
18+
KAFKA_ADVERTISED_LISTENERS: LC://kafka:29092,LX://${DOCKER_HOST_IP:-localhost}:9092
19+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LC:PLAINTEXT,LX:PLAINTEXT
20+
KAFKA_INTER_BROKER_LISTENER_NAME: LC
21+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
22+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
23+
KAFKA_HEAP_OPTS: -Xmx192m
1924

2025

2126
cdcservice:
@@ -30,15 +35,16 @@ services:
3035
SPRING_DATASOURCE_URL: jdbc:mysql://mysql/eventuate
3136
SPRING_DATASOURCE_USERNAME: mysqluser
3237
SPRING_DATASOURCE_PASSWORD: mysqlpw
33-
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.jdbc.Driver
34-
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
38+
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.cj.jdbc.Driver
39+
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
3540
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
3641
EVENTUATELOCAL_CDC_DB_USER_NAME: root
3742
EVENTUATELOCAL_CDC_DB_PASSWORD: rootpassword
3843
EVENTUATELOCAL_CDC_READ_OLD_DEBEZIUM_DB_OFFSET_STORAGE_TOPIC: "false"
3944
EVENTUATELOCAL_CDC_READER_NAME: MySqlReader
4045
EVENTUATELOCAL_CDC_OFFSET_STORE_KEY: MySqlBinlog
4146
EVENTUATELOCAL_CDC_MYSQL_BINLOG_CLIENT_UNIQUE_ID: 1234567890
47+
EVENTUATE_OUTBOX_ID: 1
4248
EVENTUATE_CDC_TYPE: EventuateLocal
4349

4450
mysql:
@@ -55,8 +61,10 @@ services:
5561

5662

5763
commandsideservice:
58-
build: ./todo-service/
59-
restart: unless-stopped
64+
build:
65+
context: ./todo-service/
66+
args:
67+
baseImageVersion: ${EVENTUATE_JAVA_BASE_IMAGE_VERSION}
6068
ports:
6169
- "8081:8080"
6270
depends_on:
@@ -67,15 +75,15 @@ services:
6775
SPRING_DATASOURCE_URL: jdbc:mysql://mysql/eventuate
6876
SPRING_DATASOURCE_USERNAME: mysqluser
6977
SPRING_DATASOURCE_PASSWORD: mysqlpw
70-
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.jdbc.Driver
71-
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
78+
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.cj.jdbc.Driver
79+
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
7280
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
73-
EVENTUATELOCAL_CDC_DB_USER_NAME: root
74-
EVENTUATELOCAL_CDC_DB_PASSWORD: rootpassword
7581

7682
querysideservice:
77-
build: ./todo-view-service/
78-
restart: unless-stopped
83+
build:
84+
context: ./todo-view-service/
85+
args:
86+
baseImageVersion: ${EVENTUATE_JAVA_BASE_IMAGE_VERSION}
7987
ports:
8088
- "8082:8080"
8189
depends_on:
@@ -86,22 +94,6 @@ services:
8694
SPRING_DATASOURCE_URL: jdbc:mysql://mysql/eventuate
8795
SPRING_DATASOURCE_USERNAME: mysqluser
8896
SPRING_DATASOURCE_PASSWORD: mysqlpw
89-
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.jdbc.Driver
90-
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
91-
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
92-
EVENTUATELOCAL_CDC_DB_USER_NAME: root
93-
EVENTUATELOCAL_CDC_DB_PASSWORD: rootpassword
94-
95-
consoleserver:
96-
image: eventuateio/eventuateio-local-console:0.15.0
97-
depends_on:
98-
- mysql
99-
- zookeeper
100-
ports:
101-
- "8085:8080"
102-
environment:
103-
SPRING_DATASOURCE_URL: jdbc:mysql://mysql/eventuate
104-
SPRING_DATASOURCE_USERNAME: mysqluser
105-
SPRING_DATASOURCE_PASSWORD: mysqlpw
97+
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.cj.jdbc.Driver
98+
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
10699
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
107-
DEBUG: kafka-node:*

0 commit comments

Comments
 (0)