Axon Framework 思维导图
2019-06-25 10:16:05 0 举报
AI智能生成
Axon Framework分布式事务解决方案,基于领域驱动设计,事件溯源机制
作者其他创作
大纲/内容
CommandBus
分发Command到对应的CommandHandler中
每个Command只会发送到一个Hanlder中
多个时,最后一个覆盖前面
SimpleCommandBus
在发送command的线程里执行Handler
保存Aggregate状态和发送事件也都在同一线程中
适用于大多数情况,默认配置
AsynchrounousCommandBus
启动新的线程
通过CachedThreadPool创建线程,默认60s清空闲置线程
DisruptorCommandBus
两组线程
有局限性
DistributedCommandBus
在不同JVM的commandbus之间建立一个“桥梁”
每个JVM上的DistributedCommandBus称之为segment
要求提供以下两个参数
CommandRouter
指明应当把Command发到哪里
其实现必须提供Routing Strategy
MetaDataRoutingStrategy使用CommandMessage中的MetaData的property来找到路由key
AnnotationRoutingStrategy使用Command中@TargetIdentifier标识的属性作为路由key,默认使用。
CommandBusConnector管理链接,提供发送、订阅方法
JGroupsConnector
SpringCloudConnector
通过结合AMQP实现分布式事件分发与处理
CommandGateway
对CommandBus的一个封装,方便发送Command
EventBus
发送Event到Handler中
SimpleEventBus
默认的,非持久化,消费者接收到后就会销毁
EmbeddedEventStore
可以持久化,方便以后replay
Repository
Aggregate持久化的方式
Standard Repositories
GenercJpaRepository
把Aggregate的最新状态保存到数据库中
Event Sourcing Repositories
事件溯源,不保存Aggregate状态,保存Event,通过Event恢复状态
EventStorageEngine
InMemoryEeventStorageEngine
JpaEventStorageEngine
JdbcEventStorageEngine
MongoEventStorageEngine
@Aggregate
定义某个class为聚合对象
必须包含@AggregateIdentfier作为全局唯一标识符
Command
任意类
发送命令操作时使用
处理时会被Aggregate封装为CommandMessage进行通讯
Event
任意类
保存事件所需要
会被封装成EventMessage进行通信
@CommandHandler
处理Command的方法
handler最终需要保存此次事件
apply静态方法发送Event
@EventHandler
处理Event的方法
@Saga
多事务的组合,以及补偿机制,实现最终一致性
@StartSaga
起点只有一个
@SagaEventHandler
需要与startSaga共用
只处理其关联的Event
associationProperty作为关联
@EndSaga
终点有多个
0 条评论
下一页