基于Eventuate的微服务应用Money Transfer分析
来源:互联网 发布:看得见风景的房间 知乎 编辑:程序博客网 时间:2024/05/29 18:09
Money Transfer是Chris Richardson在自己的官方博客提供的一个账户转账的应用示例,其核心是基于Eventuate实现的。Eventuate提供了分布式数据的最终一致性实现。
1. 在Money Transfer应用中,集中展现了微服务的如下特性:
- microservices
- polyglot persistence
- event sourcing (ES)
- command query responsibility segregation (CQRS)
2. 在Money Transfer应用中,组件的部署分为如下几个独立的服务:
- API gateway Service
- Account Service
- Account View Service
- Customer Service
- Customer View Service
- Transaction Service
其中API gateway Service否则整个应用的请求分发。其他几个是业务相关的服务,其中关键的是Transaction Service。
每个服务都有自己私有的数据库,可能是SQL,也可能是NOSQL。
跨服务的数据操作(即分布式事务)是通过event的订阅与发布而实现最终一致性。这又是借助于第三方的事件架构软件Eventuate实现的。
3. Money Transfer应用的源代码组成
- java-spring
- scala-spring
- js-frontend
- prebuilt-web-client
java-spring是应用的服务端Java实现,scala-spring是应用的服务端Scala实现。下面以java-spring为例进行分析。
1) java-spring源代码的构建与使用
- 安装Gradle(可选)
- 编译
./gradlew assemble -P eventuateDriver=local
- 启动服务
docker-compose -f docker-compose-eventuate-local.yml up -d
- 浏览器访问
2) Transaction Service的分析
3) API gateway Service的分析
在API gateway Service中,配置属性文件如下:
accounts.commandside.service.host=localhostaccounts.queryside.service.host=localhostcustomers.commandside.service.host=localhostcustomers.queryside.service.host=localhosttransfers.commandside.service.host=localhostapi.gateway.endpoints[0].path=[/]*api/accounts.*api.gateway.endpoints[0].method=GETapi.gateway.endpoints[0].location=http://${accounts.queryside.service.host}:8080api.gateway.endpoints[1].path=[/]*api/customers.*/accountsapi.gateway.endpoints[1].method=GETapi.gateway.endpoints[1].location=http://${accounts.queryside.service.host}:8080api.gateway.endpoints[2].path=[/]*api/accounts.*api.gateway.endpoints[2].method=POSTapi.gateway.endpoints[2].location=http://${accounts.commandside.service.host}:8080api.gateway.endpoints[3].path=[/]*api/customers.*api.gateway.endpoints[3].method=GETapi.gateway.endpoints[3].location=http://${customers.queryside.service.host}:8080api.gateway.endpoints[4].path=[/]*api/customers.*api.gateway.endpoints[4].method=POSTapi.gateway.endpoints[4].location=http://${customers.commandside.service.host}:8080api.gateway.endpoints[5].path=[/]*api/transfers.*api.gateway.endpoints[5].method=POSTapi.gateway.endpoints[5].location=http://${transfers.commandside.service.host}:8080api.gateway.endpoints[6].path=[/]*api/customers.*api.gateway.endpoints[6].method=DELETEapi.gateway.endpoints[6].location=http://${customers.commandside.service.host}:8080api.gateway.endpoints[7].path=[/]*api/accounts.*api.gateway.endpoints[7].method=DELETEapi.gateway.endpoints[7].location=http://${accounts.commandside.service.host}:8080可见,通过配置实现了对不同服务的聚合和调度。
参考链接:
http://eventuate.io/
http://eventuate.io/exampleapps.html
https://github.com/cer/event-sourcing-examples
阅读全文
1 0
- 基于Eventuate的微服务应用Money Transfer分析
- 关于微服务的两篇文章以及Eventuate
- 微服务中的分布式数据一致性管理软件Eventuate概述
- 基于微服务的企业应用架构设计范式
- 搭建基于Spring Cloud的微服务应用
- grpc应用于微服务的分析,基于python
- 微服务框架Finagle介绍 Part2: 在Finagle中开发基于Http协议的应用
- 微服务框架Finagle介绍 Part3: 在Finagle中开发基于Thrift协议的应用
- 基于网络抓包实现kubernetes中微服务的应用级监控
- 基于网络抓包实现kubernetes中微服务的应用级监控
- 微服务框架Finagle介绍 Part2: 在Finagle中开发基于Http协议的应用
- code force 之 Money transfer
- 基于容器的微服务架构剖析
- 基于容器的微服务架构剖析
- 基于微服务的软件架构模式
- 基于Node.js的微服务后台
- 基于微服务的软件架构模式
- 基于微服务的软件架构模式
- 深入理解Java的接口和抽象类
- C++ 函数指针 强制类型转换
- 使用FreeMaker导出excel
- spring session入门
- A Brief Tutorial on Git in Ubuntu 16.04
- 基于Eventuate的微服务应用Money Transfer分析
- jQuery中 this与event.target区别
- Qml settings 需要注意的问题
- python2和python3的区别
- 几个算法知识--希尔排序
- 机器学习——简单线性回归(上)
- 第二周项目3-体验复杂度
- 第三方合作登录平台使用说明
- u检验和t检验区别与联系