Files
nexus/wiki/concepts/Choreography.md

44 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Choreography"
type: concept
tags:
- EDA
- Architecture
- Microservices
last_updated: 2026-04-14
---
## Aliases
- Choreography Pattern
- 编舞模式
- 去中心化事件协调
## Definition
编舞模式Choreography是一种微服务间通过事件进行自发协调的模式各服务自主响应事件并发布新事件无需中央协调器。服务通过事件总线了解全局状态和下一步操作。
## Characteristics
- **Decentralized**:无中央协调器,各服务平等
- **Autonomous**:每个服务自主决定如何响应事件
- **Loosely Coupled**:服务之间完全解耦,通过事件总线交互
- **Resilient**:局部故障不影响其他服务
- **Harder to Track**:整体业务流程不直观,调试复杂
## Example
1. 订单服务发布 `OrderCreated` 事件
2. 库存服务订阅并发布 `InventoryReserved` 事件
3. 支付服务订阅并发布 `PaymentProcessed` 事件
4. 通知服务订阅并发送确认通知
## Comparison with Orchestration
| 维度 | Choreography编舞 | Orchestration编排 |
|------|---------------------|---------------------|
| 控制 | 去中心化 | 集中式 |
| 协调器 | 无 | 有Step Functions |
| 复杂度 | 局部低,整体高 | 局部高,整体低 |
| 可观测性 | 较难追踪 | 易于追踪 |
| 适用场景 | 简单、独立的服务 | 复杂、有明确业务流程 |
## Sources
- [[public-cloud-learning-sessions-opentext-event-driven-architecture-part-2-2024091]]
- [[public-cloud-learning-sessions-opentext-serverless-computing-20240903-160139-mee]]