Giter VIP home page Giter VIP logo

javaone-2016's Introduction

JavaOne 2016 Demos

This repository contains demos for JavaOne 2016.

Handling Eventual Consistency in JVM Microservices with Event Sourcing

When you’re building JVM applications in a microservice architecture, managing state becomes a distributed systems problem. Instead of being able to manage state as transactions inside the boundaries of a single monolithic application, a microservice must be able to manage consistency by using transactions that are distributed across a network of many different applications and databases. This session explores the problems of data consistency and high availability in JVM-based microservices and how to use event sourcing to solve these problems.

Wednesday, Sep 21, 3:00 p.m. - 4:00 p.m. | Parc 55 - Embarcadero

Usage

Setup your Eventuate local environment by running Docker Compose in the /microservices directory.

$ docker-compose -f docker-compose-eventuate-local.yml up -d

After each of the Eventuate containers are started, setup your environment using the /microservices/set-env.sh script. This version of the demo requires Docker Machine to retrieve the DOCKER_HOST_IP.

$ eval $(docker-machine env default)
$ sh ./microservices/set-env.sh
DOCKER_HOST_IP is 192.168.99.100

Now that the environment has been setup, you can run the example order service.

$ cd ./microservices/order-service
$ mvn spring-boot:run

If the environment is properly configured, the order-service will start up and point to the Eventuate Local containers we started with Docker Compose. The application will start up on http://localhost:8080. To test that everything is working correctly, run the e2e-test.sh script.

$ sh ./microservices/e2e-test.sh

Create new order...
Order creation successful: 6cc64067-b085-4ce7-b9a5-b63bd9f74714
GET http://localhost:8080/v1/orders/6cc64067-b085-4ce7-b9a5-b63bd9f74714
{
  "status": "CREATED",
  "id": 35,
  "entityId": "000001574a80cf8a-52d57e06d3510001",
  "orderNumber": "6cc64067-b085-4ce7-b9a5-b63bd9f74714"
}
Update Order Status: CREATED >> PENDING
Result:
{
  "status": "PENDING",
  "id": 35,
  "entityId": "000001574a80cf8a-52d57e06d3510001",
  "orderNumber": "6cc64067-b085-4ce7-b9a5-b63bd9f74714"
}
Update Order Status: PENDING >> CONFIRMED
Result:
{
  "status": "CONFIRMED",
  "id": 35,
  "entityId": "000001574a80cf8a-52d57e06d3510001",
  "orderNumber": "6cc64067-b085-4ce7-b9a5-b63bd9f74714"
}
Update Order Status: CONFIRMED >> SHIPPED
Result:
{
  "status": "SHIPPED",
  "id": 35,
  "entityId": "000001574a80cf8a-52d57e06d3510001",
  "orderNumber": "6cc64067-b085-4ce7-b9a5-b63bd9f74714"
}
Tests complete!

The e2e-test.sh script will create a new order and transition the state from CREATED to SHIPPED. Notice that the Order domain object does not have a status field persisted to MySQL. The Order object extends the OrderAggregate object, which uses Eventuate to aggregate the status of the order from a sequence of events. Pretty cool!

javaone-2016's People

Contributors

kbastani avatar cer avatar

Watchers

Minseok Kim avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.