Further modularization of the Java/Spring example

This commit is contained in:
Chris Richardson
2015-01-03 11:48:23 -08:00
parent 4c1ddb0663
commit a0e2b52ba3
42 changed files with 91 additions and 25 deletions

View File

@@ -1,11 +1,32 @@
This is the Java/Spring version of the Event Sourcing/CQRS money transfer example application.
It consists of the following modules:
This application consists of three microservices:
* Account Service - the command side business logic for Accounts
* Money Transfer Service - the command side business logic for Money Transfers
* Query service - query side implementation of a MongoDB-based, denormalized view of Accounts and MoneyTransfers
The Account Service consists of the following modules:
* commandside-backend-accounts - the Account aggregate
* commandside-web-accounts - a REST API for creating and retrieving Accounts
The Money Transfer Service consists of the following modules:
* commandside-backend-transactions - the MoneyTransfer aggregate
* commandside-web-transactions - a REST API for creating and retrieving Money Transfers
The Query Service consists the following modules:
* queryside-backend - MongoDB-based, denormalized view of Accounts and MoneyTransfers
* queryside-web - a REST API for querying the denormalized view
In order to be used with the embedded Event Store, the three services are currently packaged as a single monolithic web application:
* monolithic-web - all-in-one, monolithic packaging of the application
As well as the above modules there are also:
* common-backend - code that is shared between the command side and the query side, primarily events and value objects
* commandside-backend - the business logic, which consists of Account and MoneyTransfer aggregates
* queryside-backend - MongoDB-based, denormalized view of Accounts and MoneyTransfers
* commandside-web - a REST API for creating and retrieving Accounts and MoneyTransfers
* queryside-web - a REST API for querying the MongoDB-based, denormalized view of Account
* monolithic-web - all-in-one, monolithic packaging of the application
* backend-integration-tests - integrations tests for the backend

View File

@@ -1,6 +1,7 @@
dependencies {
testCompile project(":commandside-backend")
testCompile project(":commandside-backend-accounts")
testCompile project(":commandside-backend-transactions")
testCompile project(":queryside-backend")
testCompile project(":testutil")
testCompile "junit:junit:4.11"

View File

@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking;
package net.chrisrichardson.eventstore.javaexamples.banking.backend;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.accounts.AccountConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.transactions.MoneyTransferConfiguration;

View File

@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking;
package net.chrisrichardson.eventstore.javaexamples.banking.backend;
import net.chrisrichardson.eventstore.EntityWithIdAndVersion;
import net.chrisrichardson.eventstore.EntityWithMetadata;

View File

@@ -1,7 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.accounts;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.AbstractEntityEventTest;
import net.chrisrichardson.eventstorestore.javaexamples.testutil.AbstractEntityEventTest;
public class AccountEventTest extends AbstractEntityEventTest {

View File

@@ -0,0 +1,19 @@
apply plugin: 'java'
dependencies {
compile project(":common-backend")
compile "net.chrisrichardson.eventstore.client:eventstore-java-client:$eventStoreClientVersion"
compile "org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion"
compile 'com.fasterxml.jackson.core:jackson-core:2.4.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.3'
compile 'com.fasterxml.jackson.module:jackson-module-scala_2.10:2.4.3'
testCompile project(":testutil")
testCompile "junit:junit:4.11"
testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
testCompile "net.chrisrichardson.eventstore.client:eventstore-jdbc:$eventStoreClientVersion"
}

View File

@@ -1,6 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.transactions;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.AbstractEntityEventTest;
import net.chrisrichardson.eventstorestore.javaexamples.testutil.AbstractEntityEventTest;
public class MoneyTransferEventTest extends AbstractEntityEventTest {

View File

@@ -1,6 +1,6 @@
dependencies {
compile project(":commandside-backend")
compile project(":commandside-backend-accounts")
compile project(":web-common")
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"

View File

@@ -0,0 +1,13 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.accounts;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.accounts.AccountConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@Configuration
@Import({AccountConfiguration.class})
@ComponentScan
public class CommandSideWebAccountsConfiguration {
}

View File

@@ -0,0 +1,10 @@
dependencies {
compile project(":commandside-backend-transactions")
compile project(":web-common")
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
}

View File

@@ -1,14 +1,13 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web.commandside;
package net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.accounts.AccountConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.transactions.MoneyTransferConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@Configuration
@Import({AccountConfiguration.class, MoneyTransferConfiguration.class})
@Import({MoneyTransferConfiguration.class})
@ComponentScan
public class CommandSideWebConfiguration {
public class CommandSideWebTransactionsConfiguration {
}

View File

@@ -1,7 +1,5 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.accounts.CreateAccountResponse;
import java.math.BigDecimal;
public class CreateMoneyTransferRequest {

View File

@@ -2,7 +2,8 @@ apply plugin: 'spring-boot'
dependencies {
compile project(":queryside-web")
compile project(":commandside-web")
compile project(":commandside-web-accounts")
compile project(":commandside-web-transactions")
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"

View File

@@ -1,6 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.CommandSideWebConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.accounts.CommandSideWebAccountsConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions.CommandSideWebTransactionsConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.web.queryside.QuerySideWebConfiguration;
import net.chrisrichardson.eventstore.jdbc.config.JdbcEventStoreConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -13,7 +14,7 @@ import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@Configuration
@Import({CommandSideWebConfiguration.class, JdbcEventStoreConfiguration.class, QuerySideWebConfiguration.class})
@Import({CommandSideWebAccountsConfiguration.class, CommandSideWebTransactionsConfiguration.class, JdbcEventStoreConfiguration.class, QuerySideWebConfiguration.class})
@EnableAutoConfiguration
@ComponentScan
public class BankingWebConfiguration {

View File

@@ -3,8 +3,10 @@ include 'web-common'
include 'common-backend'
include 'commandside-backend'
include 'commandside-web'
include 'commandside-backend-accounts'
include 'commandside-backend-transactions'
include 'commandside-web-accounts'
include 'commandside-web-transactions'
include 'queryside-backend'

View File

@@ -6,8 +6,8 @@ dependencies {
compile 'com.fasterxml.jackson.core:jackson-core:2.4.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.3'
compile 'com.fasterxml.jackson.module:jackson-module-scala_2.10:2.4.3'
compile "junit:junit:4.11"
testCompile "junit:junit:4.11"
testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
testCompile "net.chrisrichardson.eventstore.client:eventstore-jdbc:$eventStoreClientVersion"

View File

@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside;
package net.chrisrichardson.eventstorestore.javaexamples.testutil;
import net.chrisrichardson.eventstore.Aggregate;
import net.chrisrichardson.eventstore.ReflectiveMutableCommandProcessingAggregate;