Skip to content

Commit

Permalink
cer#44: Upgraded eventuate dependencies. Upgraded Spring boot. Upgrad…
Browse files Browse the repository at this point in the history
…ed gradle. Updated according the style guide.
  • Loading branch information
dartartem committed Oct 23, 2020
1 parent 7dcafe5 commit e0d0ccb
Show file tree
Hide file tree
Showing 272 changed files with 998 additions and 3,851 deletions.
43 changes: 4 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ There is also an [API gateway](http://microservices.io/patterns/apigateway.html)

# About the examples

There are currently the following versions of the example application:

* java-spring - a Java and Spring Boot example
* scala-spring - a Scala and Spring Boot example (NOTE: this version is lagging the Java Spring and hasn't been updated in a longtime.)

Other examples will be added shortly including a Scala/Play example.
There is currently a Java and Spring Boot example: java-spring

For more information, please see the [wiki](../../wiki)

Expand All @@ -63,9 +58,6 @@ It provides a simple yet powerful event-driven programming model that is based o
Eventuate solves the distributed data management problems inherent in a microservice architecture.
It consists of a scalable, distributed event store and client libraries for various languages and frameworks including Java, Scala, and the Spring framework.

There are two versions of Eventuate:

* [Eventuate SaaS server](http://eventuate.io/usingeventuate.html) - this is a full featured event store that is hosted on AWS
* [Eventuate Local](http://eventuate.io/usingeventuate.html) - an open-source event store that is built using MySQL and Kafka

There is also an embedded test event store, which is great for integration tests.
Expand All @@ -78,46 +70,19 @@ You just need to have Java 8 installed.

The details of how to build and run the services depend slightly on whether you are using Eventuate SaaS or Eventuate Local.

## Building and running using Eventuate SaaS

First, must [sign up to get your credentials](https://signup.eventuate.io/) in order to get free access to the SaaS version.

Next, build the application

```
cd java-spring
./gradlew assemble
```

Next, you can launch the services using [Docker Compose](https://docs.docker.com/compose/):

```
docker-compose up -d
```

Finally, you can open the home page, which is served up by the API Gateway: `http://$DOCKER_HOST_IP:8080`

Note: `DOCKER_HOST_IP` is the IP address of the machine where Docker is running, e.g. the IP address of the VirtualBox VM.

## Building and running using Eventuate Local

First, build the application

```
cd java-spring
./gradlew assemble -P eventuateDriver=local
./gradlew assemble
```

Next, launch the services using [Docker Compose](https://docs.docker.com/compose/):

```
export DOCKER_HOST_IP=...
docker-compose -f docker-compose-eventuate-local.yml up -d
./gradlew mysqlbinlogComposeUp
```

Note: You need to set `DOCKER_HOST_IP` before running Docker Compose.
This must be an IP address or resolvable hostname.
It cannot be `localhost`.
See this [guide to setting `DOCKER_HOST_IP`](http://eventuate.io/docs/usingdocker.html) for more information.

Finally, you can open the home page, which is served up by the API Gateway: `http://$DOCKER_HOST_IP:8080`
Finally, you can open the home page, which is served up by the API Gateway: `http://localhost:8080`
70 changes: 0 additions & 70 deletions _build-and-test-all.sh

This file was deleted.

9 changes: 9 additions & 0 deletions java-spring/accounts-service-api-messaging/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apply plugin: 'java'

dependencies {
compile project(":common")

compile "io.eventuate.local.java:eventuate-client-java-spring:$eventuateLocalVersion"

testCompile "junit:junit:4.11"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events;

import java.math.BigDecimal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events;

import java.math.BigDecimal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events;

public class AccountDebitFailedDueToInsufficientFundsEvent extends AccountEvent {
private String transactionId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events;

import java.math.BigDecimal;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events;

public class AccountDeletedEvent extends AccountEvent {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events;

import io.eventuate.Event;
import io.eventuate.EventEntity;

@EventEntity(entity="net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.backend.Account")
@EventEntity(entity="net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.domain.Account")
public abstract class AccountEvent implements Event{
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events;

import java.math.BigDecimal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events;

import io.eventuate.javaclient.commonimpl.JSonMapper;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts.AccountOpenedEvent;
import io.eventuate.common.json.mapper.JSonMapper;
import net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events.AccountOpenedEvent;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -14,7 +14,6 @@ public void shouldSerde() {

AccountOpenedEvent event = new AccountOpenedEvent("00000000-00000000", "My Account", new BigDecimal(55), "");
String json = JSonMapper.toJson(event);
System.out.println("json=" + json);

AccountOpenedEvent event2 = JSonMapper.fromJson(json, AccountOpenedEvent.class);

Expand Down
5 changes: 5 additions & 0 deletions java-spring/accounts-service-api-web/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apply plugin: 'java'

dependencies {
compile project(":common")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.webapi;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.webapi;


public class CreateAccountResponse {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.common.accounts;
package net.chrisrichardson.eventstore.javaexamples.banking.accounts.webapi;


public class DeleteAccountResponse {
Expand Down
7 changes: 3 additions & 4 deletions java-spring/accounts-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
FROM java:openjdk-8u91-jdk
CMD java ${JAVA_OPTS} -jar accounts-service.jar
EXPOSE 8080
COPY build/libs/accounts-service.jar .
ARG baseImageVersion
FROM eventuateio/eventuate-examples-docker-images-spring-example-base-image:$baseImageVersion
COPY build/libs/accounts-service.jar service.jar
28 changes: 15 additions & 13 deletions java-spring/accounts-service/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
apply plugin: VerifyEventStoreEnvironmentPlugin
apply plugin: EventuateDependencyPlugin

apply plugin: 'spring-boot'
apply plugin: 'org.springframework.boot'

dependencies {
compile project(":common-backend")
compile project(":common-swagger")

compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile project(":accounts-service-api-messaging")
compile project(":accounts-service-api-web")

compile project(":transactions-service-api-messaging")

compile "io.eventuate.local.java:eventuate-local-java-spring-jdbc:$eventuateLocalVersion"

compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
compile "org.springframework.boot:spring-boot-starter-hateoas:$springBootVersion"
compile "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
compile "org.springframework.boot:spring-boot-starter-jdbc:$springBootVersion"

testCompile project(":common-auth")
testCompile project(":testutil")
testCompile "junit:junit:4.11"
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "io.eventuate.client.java:eventuate-client-java-jdbc:$eventuateClientVersion"
}

test {
ignoreFailures System.getenv("EVENTUATE_API_KEY_ID") == null
testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
testCompile "io.eventuate.local.java:eventuate-client-java-spring-jdbc:$eventuateLocalVersion"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.backend;
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice;

import io.eventuate.AggregateRepository;
import io.eventuate.EventuateAggregateStore;
import io.eventuate.javaclient.spring.EnableEventHandlers;
import net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.domain.Account;
import net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.domain.AccountCommand;
import net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.service.AccountService;
import net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.service.AccountWorkflow;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableEventHandlers
public class AccountsBackendConfiguration {
public class AccountsConfiguration {

@Bean
public AccountWorkflow accountWorkflow() {
Expand All @@ -25,7 +29,6 @@ public AccountService accountService(AggregateRepository<Account, AccountCommand
public AggregateRepository<Account, AccountCommand> accountRepository(EventuateAggregateStore eventStore) {
return new AggregateRepository<Account, AccountCommand>(Account.class, eventStore);
}

}


Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice;

import io.eventuate.javaclient.driver.EventuateDriverConfiguration;
import io.eventuate.local.java.spring.javaclient.driver.EventuateDriverConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.web.AccountsWebConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.commonswagger.CommonSwaggerConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@Import({AccountsWebConfiguration.class, EventuateDriverConfiguration.class, CommonSwaggerConfiguration.class})
@Import({AccountsConfiguration.class, AccountsWebConfiguration.class, EventuateDriverConfiguration.class})
@EnableAutoConfiguration
@ComponentScan
public class AccountsServiceMain {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.backend;
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.domain;

import io.eventuate.Event;
import io.eventuate.EventUtil;
import io.eventuate.ReflectiveMutableCommandProcessingAggregate;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts.*;
import net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events.AccountCreditedEvent;
import net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events.AccountDebitFailedDueToInsufficientFundsEvent;
import net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events.AccountDebitedEvent;
import net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events.AccountDeletedEvent;
import net.chrisrichardson.eventstore.javaexamples.banking.accounts.domain.events.AccountOpenedEvent;

import java.math.BigDecimal;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.backend;
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.domain;


import io.eventuate.Command;

interface AccountCommand extends Command {
public interface AccountCommand extends Command {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.backend;
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.domain;

import java.math.BigDecimal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.backend;
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.domain;

import java.math.BigDecimal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.backend;
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.domain;

public class DeleteAccountCommand implements AccountCommand {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.backend;
package net.chrisrichardson.eventstore.javaexamples.banking.accountsservice.domain;


import java.math.BigDecimal;
Expand Down
Loading

0 comments on commit e0d0ccb

Please sign in to comment.