LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Service Developer

Microservices enable businesses to innovate faster and stay ahead of the competition. But one major challenge with the microservices architecture is the management of distributed data. Each microservice has its own private database. It is difficult to implement business transactions that maintain data consistency across multiple services as well as queries that retrieve data from multiple services.

The light-eventuate-4j is an event sourcing and CQRS framework which provides a simple yet powerful event-driven programming model that solves the distributed data management problems inherent in a microservice architecture.

The programming model is based on two well established patterns: Event Sourcing (ES) and Command Query Responsibility Segregation (CQRS).

light-eventuate-4j consists of a scalable, distributed event store server and client libraries for frameworks like light-rest-4j, light-graphql-4j and light-hybrid-4.

This tutorial is for developers who are interested in building services that leverage the light-eventuate-4j framework for service to service communication. If you want to work on the components in light-eventuate-4j, please follow this tutorial to set up your working environment.

Also, the following steps assume that you have docker installed on your computer. Your OS should be Linux or Mac. Windows these days is still not Docker friendly and there are some issues with docker-compose.

Setting DOCKER_HOST_IP for Mac

You can install Mysql, Kafka individually and start them at an OS level. This is the only option if you are using Windows. However, the most convenient way is to use docker-compose to run the application services and eventuate infrastructure services: Mysql, Zookeeper, Kafka and CDC server.

When using Docker container for Kafka, you need to export DOCKER_HOST_IP with your local network IP address. This variable sets the advertised listener of the Kafka container. It must be an IP address (or a DNS name) that is accessible from both Docker containers and, if you want to do development, from applications running on the host. Unfortunately, because of version/platform-specific variations in how Docker works, setting this variable is a little tricky.

Docker for Mac has networking limitations and you need to follow the steps below to set it up.

sudo ifconfig lo0 alias 10.200.10.1/24  # (where 10.200.10.1 is some unused IP address)
export DOCKER_HOST_IP=10.200.10.1

Once you have complete the export command, please use the same terminal to start docker-compose-eventuate.yml described in the next step as other terminal doesn’t have this DOCKER_HOST_IP set.

For more information on the DOCKER_HOST_IP, please refer to getting started

Start Mysql, Zookeeper and Kafka

Assuming you have a working directory under your home directory called networknt

cd ~/networknt
git clone https://github.com/networknt/light-docker.git
cd light-docker
docker-compose -f docker-compose-eventuate.yml down
docker-compose -f docker-compose-eventuate.yml up

In case the last time docker-compose is not shutdown cleanly, we run docker-compose down first before up.

Start CDC server

Open another terminal to start CDC server with another docker-compose.

Note: You have to wait until above Mysql, Zookeeper and Kafka compose are all started successfully before running the docker-compose-cdcserver.

cd ~/networknt/light-docker
docker-compose -f docker-compose-cdcserver-for-eventuate.yml up

Start Hybrid Command and Query servers

If you are using light-hybrid-4j to develop microservices, you don’t need to start CDC server in the above step. There is a cdc-service available and it can be started with other command side services and share the same hybrid command server.

Here are the steps to start both command server and query server.

cd ~/networknt/light-docker
docker-compose -f docker-compose-hybrid.yml up

Note: you only need start one CDC server or service as they provide the same service just different implementations - rest vs hybrid.

Once you have your dev environment setup, you can follow the todo-list tutorial to get started.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Service Developer” was last updated: July 5, 2021: fixes #275 checked and corrected grammar/spelling for majority of pages (#276) (b3bbb7b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute