All Projects → chaokunyang → Microservices Event Sourcing

chaokunyang / Microservices Event Sourcing

Licence: apache-2.0
Microservices Event Sourcing 是一个微服务架构的在线购物网站,使用Spring Boot、Spring Cloud、Spring Reactor、OAuth2、CQRS 构建,实现了基于Event Sourcing的最终一致性,提供了构建端到端微服务的最佳实践

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Microservices Event Sourcing

Event Sourcing Jambo
An Hexagonal Architecture with DDD + Aggregates + Event Sourcing using .NET Core, Kafka e MongoDB (Blog Engine)
Stars: ✭ 159 (-75.8%)
Mutual labels:  microservice, event-sourcing, event-driven, mongodb
Event Sourcing Castanha
An Event Sourcing service template with DDD, TDD and SOLID. It has High Cohesion and Loose Coupling, it's a good start for your next Microservice application.
Stars: ✭ 68 (-89.65%)
Mutual labels:  microservice, event-sourcing, event-driven, mongodb
Event Sourcing Microservices Example
Learn about building microservices with event sourcing using Spring Boot and how to deploy a social network to Kubernetes using Docker Compose or Helm.
Stars: ✭ 167 (-74.58%)
Mutual labels:  event-sourcing, event-driven, neo4j, spring-boot
Testcontainers Spring Boot
Container auto-configurations for spring-boot based integration tests
Stars: ✭ 460 (-29.98%)
Mutual labels:  mongodb, neo4j, spring-boot
Eventflow.example
DDD+CQRS+Event-sourcing examples using EventFlow following CQRS-ES architecture. It is configured with RabbitMQ, MongoDB(Snapshot store), PostgreSQL(Read store), EventStore(GES). It's targeted to .Net Core 2.2 and include docker compose file.
Stars: ✭ 131 (-80.06%)
Mutual labels:  event-sourcing, event-driven, mongodb
Event Driven Spring Boot
Example Application to demo various flavours of handling domain events in Spring Boot
Stars: ✭ 194 (-70.47%)
Mutual labels:  event-sourcing, event-driven, spring-boot
Mall
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Stars: ✭ 54,797 (+8240.49%)
Mutual labels:  mongodb, spring-boot, springcloud
Goodskill
🐂基于springcloud +dubbo构建的模拟秒杀项目,模块化设计,集成了分库分表、elasticsearch🔍、gateway、mybatis-plus、spring-session等常用开源组件
Stars: ✭ 786 (+19.63%)
Mutual labels:  microservice, mongodb, springcloud
Febs Cloud
基于Spring Cloud Hoxton.RELEASE、Spring Cloud OAuth2 & Spring Cloud Alibaba & Element 微服务权限系统,开箱即用。预览地址:https://cloud.mrbird.cn
Stars: ✭ 1,295 (+97.11%)
Mutual labels:  microservice, spring-boot, oauth2
Mcloud
基于Spring Cloud,实现微服务中常用的基础模块,包括 OAuth2 认证服务,统一注册中心,系统监控中心, 统一配置中心,API网关以及熔断器
Stars: ✭ 185 (-71.84%)
Mutual labels:  microservice, spring-boot, oauth2
Space Cloud
Open source Firebase + Heroku to develop, scale and secure serverless apps on Kubernetes
Stars: ✭ 3,323 (+405.78%)
Mutual labels:  microservice, event-driven, mongodb
Cola Cloud
Cola Cloud 基于 Spring Boot, Spring Cloud 构建微服务架构企业级开发平台,集成OAuth2认证、集成短信验证码登录、微信小程序登录、FlyWay数据库版本管理、网关集成Swagger聚合所有服务API文档。基于SpringBootAdmin集成Hystrix、Turbine监控。开发用户中心、权限管理、组织架构、数据字典、消息中心、通知中心等模块。基于MyBatisPlus Generator 开发代码生成器
Stars: ✭ 285 (-56.62%)
Mutual labels:  microservice, spring-boot, oauth2
Springbootlearning
《Spring Boot教程》源码
Stars: ✭ 2,065 (+214.31%)
Mutual labels:  mongodb, spring-boot, springcloud
Dotnet New Caju
Learn Clean Architecture with .NET Core 3.0 🔥
Stars: ✭ 228 (-65.3%)
Mutual labels:  event-sourcing, event-driven, mongodb
My Moments
Instagram Clone - Cloning Instagram for learning purpose
Stars: ✭ 140 (-78.69%)
Mutual labels:  mongodb, neo4j, spring-boot
Run Aspnetcore Microservices
Microservices on .Net platforms which used Asp.Net Web API, Docker, RabbitMQ, MassTransit, Grpc, Ocelot API Gateway, MongoDB, Redis, PostgreSQL, SqlServer, Dapper, Entity Framework Core, CQRS and Clean Architecture implementation. Also includes Cross-Cutting concerns like Implementing Centralized Distributed Logging with Elasticsearch, Kibana and SeriLog, use the HealthChecks with Watchdog, Implement Retry and Circuit Breaker patterns with Polly and so on.. See Microservices Architecture and Step by Step Implementation on .NET Course w/ discount->
Stars: ✭ 406 (-38.2%)
Mutual labels:  event-sourcing, event-driven, mongodb
Spring Boot Examples
about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。
Stars: ✭ 26,812 (+3980.97%)
Mutual labels:  mongodb, spring-boot, springcloud
Easy Notes
🍋 简笔记(easy notes)打造你的轻便私人笔记。接口涉及Spring Security、OAuth2、Jwt、MongoDB,客户端采用 Vue.js 、Ant Design
Stars: ✭ 89 (-86.45%)
Mutual labels:  mongodb, spring-boot, oauth2
Chronus
Chronus是360金融技术团队基于阿里开源项目TBSchedule重写的分布式调度。
Stars: ✭ 166 (-74.73%)
Mutual labels:  microservice, spring-boot, springcloud
Micro Company
Rest-full, Hipermedia-based distributed application. Spring boot & cloud. Angular. CQRS. Eventsourcing. Axonframework. Microservices. Docker. CloudFoundry
Stars: ✭ 307 (-53.27%)
Mutual labels:  microservice, event-sourcing, spring-boot

Microservices Event Sourcing

一、简介

Microservices Event Sourcing 是一个微服务架构的在线购物平台,使用Spring Boot、Spring Cloud、Spring Reactor、OAuth2、CQRS 构建,实现了基于Event Sourcing的最终一致性,提供了构建端到端微服务的最佳实践。

微服务优点

微服务是最近几年很流行的一种架构模式,相比其他架构模式有着诸多优点。如:

  • 每个微服务很小
    • 易于开发者理解,上手快,易开发、易重构
    • IDE更快,使得开发更具生产力
    • 启动速度更快,也使得开发更具生产力,同时加快应用部署
  • 每个服务可以独立部署,从而更容易频繁部署新版本的服务
  • 容易扩大开发规模。微服务使你能够跨团队开发。每个团队服务自己的一个或多个单一服务。每个团队可以独立于其他团队开发、部署、伸缩他们的服务
  • 改善故障隔离。比如,如果一个服务内存泄漏,那么只有这个服务被影响,其它服务仍然能够继续处理请求。而在单体架构中,一个不工作的组件可能拖垮整个系统
  • 每个服务可以独立开发和部署,易于持续集成/交付
  • 避免长期绑定到一个技术栈。当开发一个新的服务时,你可以使用一个新的技术栈。类似地,当对一个已有服务做出大的改动时,你可以使用一种新的技术栈轻松重写它。

微服务缺点

微服务不是银弹,它也有着自己的缺点:

  • 一个分布式系统天然的复杂性
    • 测试更加困难
    • 开发者必须实现服务通信机制
    • 数据的一致性问题
  • 部署复杂性。在生产环境中,还存在着部署和管理一个由很多不同类型服务组成的系统的运维复杂性
  • 中小规模下增加的资源消耗。在中小规模下,微服务比单体应用消耗更多资源。在大规模环境下,微服务凭借其独立部署的优势能够比单体应用有更好的资源利用率。

微服务模式

业界对于微服务开发已经有了一套实践模式,如:

  • 服务注册
  • 服务发现
  • 负载均衡
  • 配置管理
  • 断路器
  • API网关
  • 每个服务一个数据库
  • 消息驱动的微服务
  • 事件源
  • CQRS
  • 访问令牌
  • 消费者驱动的契约测试
  • 日志聚合
  • 应用监控
  • 审计日志
  • 分布式追踪
  • 异常追踪
  • 健康监测
  • 每个服务一个容器

这些微服务模式中的大多数都已经被Spring Cloud(套件)所实现,且开箱即用。但有一些需要经过一番努力才能够实现,如基于事件源实现最终一致性,命令查询职责分离(CQRS),消息驱动的微服务。而这些模式对于微服务能否成功落地至关重要。因此,Microservices Event Sourcing项目在提供构建端到端微服务的最佳实践的同时,主要关注于基于事件源实现最终一致性。我将在接下来分别构建基于CQRS的微服务,和消息驱动的微服务。

Microservices Event Sourcing架构

整个系统分为三层:

  • web层:在线商店Web,负责请求和UI
  • backing层:服务发现、边缘服务、配置服务、用户服务、监控服务
  • backend层:目录服务、库存服务、账户服务、购物车服务、订单服务

包含以下微服务.:

  • Config Service
  • Discovery Service
  • Edge Service
  • User Service
  • Catalog Service
  • Account Service
  • Order Service
  • Inventory Service
  • Shopping Cart Service
  • Online Store Web
  • Hystrix Dashboard

数据库

微服务架构通常使用多个数据库。业务领域的资源分布在整个微服务架构中,每个微服务有它单独的数据库。开发团队通常根据数据库在解决特定问题时其优势选择合适类型的数据库。

Microservices Event Sourcing使用以下数据库类型.

  • MySQL - RDBMS
  • Neo4j - GraphDB
  • MongoDB - Document Store
  • Redis - Key/value Store

即使是同种类型的数据库,每个服务也应该使用单独的数据库,这是微服务的基本模式之一,能够避免引起数据库层面的耦合,也易于维护、扩展、伸缩.

二、Getting Started

1、分别为user-service、account-service、catalog-service、shopping-cart-service创建单独的mysql数据库与用户

CREATE  DATABASE time_store_user CHARACTER SET  utf8  COLLATE utf8_general_ci;
grant all privileges on time_store_user.* to 'time'@'localhost' identified by '123456';
grant all privileges on time_store_user.* to 'time'@'127.0.0.1' identified by '123456';
grant all privileges on time_store_user.* to 'time'@'::1' identified by '123456';
flush privileges;
CREATE  DATABASE time_store_account CHARACTER SET  utf8  COLLATE utf8_general_ci;
grant all privileges on time_store_account.* to 'time'@'localhost' identified by '123456';
grant all privileges on time_store_account.* to 'time'@'127.0.0.1' identified by '123456';
grant all privileges on time_store_account.* to 'time'@'::1' identified by '123456';
flush privileges;
CREATE  DATABASE time_store_catalog CHARACTER SET  utf8  COLLATE utf8_general_ci;
grant all privileges on time_store_catalog.* to 'time'@'localhost' identified by '123456';
grant all privileges on time_store_catalog.* to 'time'@'127.0.0.1' identified by '123456';
grant all privileges on time_store_catalog.* to 'time'@'::1' identified by '123456';
flush privileges;
CREATE  DATABASE time_store_cart CHARACTER SET  utf8  COLLATE utf8_general_ci;
grant all privileges on time_store_cart.* to 'time'@'localhost' identified by '123456';
grant all privileges on time_store_cart.* to 'time'@'127.0.0.1' identified by '123456';
grant all privileges on time_store_cart.* to 'time'@'::1' identified by '123456';
flush privileges;

2、为inventory-service安装neo4j 2.3,启动neo4j并修改密码为secret

curl -v -u neo4j:neo4j -X POST localhost:7474/user/neo4j/password -H "Content-type:application/json" -d "{\"password\":\"secret\"}"

3、为order-service安装mongo。在 localhost:27017上启动mongo

4、依次启动以下微服务

  • Discovery Service
  • Edge Service
  • User Service
  • Catalog Service
  • Account Service
  • Order Service
  • Inventory Service
  • Shopping Cart Service
  • Online Store Web

为了节省内存,以下服务可以不启动,它们对于业务开发没有很大影响

  • Hystrix Dashboard
  • Config Service

当所有服务启动完成后,验证服务已经成功注册到Eureka

如果每个服务成功加载,浏览在线购物网站首页。点击登录,你将被重定向到Oauth2.0授权服务器,即user-service。用户名是 user,密码是 password。你将被认证和请求允许对在线购物网站进行令牌授权。在完成授权后,你将被重定向到在线购物网站,然后便可以访问来自边缘服务的受保护资源。

三、预览

  • 首页未登录 首页未登录
  • OAuth2.0登录 OAuth2.0登录
  • Oauth2.0授权 Oauth2.0授权
  • 首页已登录 首页已登录
  • 商品详情 商品详情
  • 购物车 购物车
  • 订单列表 订单列表
  • 订单详情 订单详情
  • 用户设置 订单详情

四、License

This project is licensed under Apache License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].