eventuate-tram / eventuate-tram-core-examples-basic

Basic examples for Eventuate Tram
Other
38 stars 31 forks source link

= An Eventuate project

image::https://eventuate.io/i/logo.gif[]

This project is part of http://eventuate.io[Eventuate], which is a microservices collaboration platform.

= Eventuate Tram basic examples

https://github.com/eventuate-tram/eventuate-tram-core[Eventuate Tram] implements transactional messaging for microservices written using JDBC. This project implements the examples shown in that project's https://github.com/eventuate-tram/eventuate-tram-core[README].

It consists of the following modules:

== About eventuate-tram-examples-common

This module defines the transactional messaging examples:

You can run the examples using the tests in the eventuate-tram-examples-in-memory and eventuate-tram-examples-jdbc-kafka modules.

== About eventuate-tram-examples-in-memory - running in-memory examples

This module executes the examples using eventuate-tram-in-memory module, which is extremely useful for writing fast running tests.

To run this version of the tests:

./gradlew :eventuate-tram-examples-in-memory:test

== About eventuate-tram-examples-jdbc-kafka - running examples with MySQL and Apache Kafka

This module executes the examples using MySQL and Apache Kafka.

=== Set DOCKER_HOST_IP environment variable

Before running MySQL and Apache Kafka using Docker Compose, you first need to set the DOCKER_HOST_IP environment variable. This must be an IP address or resolvable hostname. It cannot be localhost or 127.0.0.1. Please see this http://eventuate.io/docs/usingdocker.html[guide to setting DOCKER_HOST_IP] for more information.

=== Run MySQL and Apache Kafka

Once you have set DOCKER_HOST_IP you can then run MySQL and Apache Kafka using Docker Compose.

gradlew <database><mode>ComposeBuild
gradlew <database><mode>ComposeUp

where one of

=== Run the tests

Once the containers have started you can run the tests:

./gradlew :eventuate-tram-examples-jdbc-kafka:test

=== Inspect the database

You can inspect the Eventuate Tram-related database tables:

$ ./mysql-cli.sh -it
Welcome to the MySQL monitor.  Commands end with ; or \g.
...

mysql> select * from message\G
*************************** 1. row ***************************
         id: 00000168d96469db-acde480011220000
destination: destination1549835461824
    headers: {"DESTINATION":"destination1549835461824","ID":"00000168d96469db-acde480011220000"}
    payload: Hello1549835461824
  published: 0

...
mysql> select * from received_messages\G
*************************** 1. row ***************************
consumer_id: commandDispatcheId1549835467791
 message_id: 00000168d9647f65-acde480011220000
*************************** 2. row ***************************
...
mysql> quit
Bye

=== Clean up

To clean up:

./gradlew <database><mode>ComposeDown

== For more information

Please read the http://eventuate.io/tram/gettingstarted.html[Eventuate Tram getting started guide] or look at the http://eventuate.io/exampleapps.html[examples].