Code Monkey home page Code Monkey logo

flowing-retail-old's Introduction

Flowing retail sample application

This sample application showcases concepts and alternatives to implement

  • a simple order application

in the context of

  • Domain Driven Design (DDD)
  • Event Driven Architecture (EDA)
  • Microservices (µS)

Key facts:

  • Written in Java
  • As simple as possible to show concepts, not build for production usage. Hint: we know some parts in the code skip well known best practices and patterns, but we focussed on making the code easy to understand. For example we prefer to duplicate code, if this means you have to read one class less to understand what a component is doing.

Links

Overview and architecture

Flowing retail simulates a very easy order processing system. The business logic is separated into the following microservices:

Microservices

  • The core domains communicate via messages with each other.
  • Messages might contain events or commands.

This is the stable nucleus for flowing retail.

Alternatives

Now there are a couple of options you can choose of when running / inspecting the example.

Channel technology

You can choose between:

  • Apache Kafka as event bus (option kafka, default).
  • RabbitMQ as AMQP messaging system (option rabbit).

Long running processes

In order to support long running processes there are multiple options, which are very interessting to compare:

  • Domain entities store state (option entity)
  • Camunda workflow engine orchestrates using BPMN models (option camunda, default)
  • Camunda workflow engine orchestrates using a technical DSL (option camunda-dsl)

Note that every component does its own parts of the overall order process. As an example this is illustrated using BPMN and showing the Order and Payment Service with their processes:

Events and Commands

Run the application

  • Download or clone the source code
  • Run a full maven build
mvn install
  • Start all components by in one Java process
    • Channel (e.g. Kafka which also requires Zookeeper)
    • All microservices
mvn -f starter exec:java

If you want to select options you can also do so:

mvn -f starter exec:java -Dexec.args="rabbit camunda-dsl"

You can also import the projects into your favorite IDE and start the following class yourself:

starter/io.flowing.retail.command.SimpleStarter

TODO ZONE

Using Kafka

  • Can be started built in, but you can also install and run yourself
  • Port = default = ##

When installed yourself, create topic "flowing-retail"

kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic flowing-retail

You can query all topics by:

kafka-topics.sh --list --zookeeper localhost:2181

Using RabbitMQ

  • Must be installed and started yourself
  • Port = default = ##

Using Camunda

You can inspect what's going on using Cockpit:

  • Download Camunda Distribution of your choice
  • Configure Datasource to connect to: jdbc:h2:tcp://localhost:8092/mem:camunda
    • In Tomcat distribution this is configured in server/apache-tomcat-8.0.24/conf/server.xml
    • In Wildfly distribution this is configred in server/wildfly-10.1.0.Final/standalone/configuration/standalone.xml
  • Best: Do not start job executor
  • Run it and you can use cockpit normally

If you want to restart microservices and keep cockpit running, you have to make sure your JDBC connection pool destroys stale connections. In Wildfly you can add a valdidation to your datasource, so the config will look like this:

<datasource jndi-name="java:jboss/datasources/ProcessEngine" pool-name="ProcessEngine" ...>
    <connection-url>jdbc:h2:tcp://localhost:8092/mem:camunda</connection-url>
    <driver>h2</driver>
    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
    <security>
        <user-name>sa</user-name>
        <password>sa</password>
    </security>
    <validation>
        <check-valid-connection-sql>select 1</check-valid-connection-sql>
        <validate-on-match>false</validate-on-match>
    </validation>
</datasource>

flowing-retail-old's People

Contributors

berndruecker avatar martinschimak avatar mihbor 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.