知识卡片
发布订阅解身份耦合
发布者只发事件或主题,不显式调用消费者;事件总线管理订阅并派发,新增订阅者通常不要求改发布者。可记录重放事件以复现问题,但订阅映射小改也可能产生广泛行为变化。异步时延、执行顺序、资源和测试更难推理,端到端安全也需另行设计,不应把松耦合当确定性保证。
结构图:
flowchart LR
P[发布者] -->|事件或主题| B[事件总线]
S[订阅者] -->|登记兴趣| B
B -->|匹配后派发| S
相关:[[变化传播揭示内聚耦合]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 可修改性 · 查看原书依据
The publishers have no knowledge of the subscribers, and subscribers are only aware of message types. Systems using the publish-subscribe pattern rely on implicit invocation; that is, the component publishing a message does not directly invoke any other component.
参考来源
- 位置:《Software Architecture in Practice, 4th Edition》第8章《可修改性》(来源项目:book-sources;源文件:extracted/Software Architecture in Practice, 4th Edition/_epub-src/ch08.html)
- 结论依据:原文的定义、机制或比较支持“发布者只发事件或主题,不显式调用消费者;事件总线管理订阅并派发,新增订阅者通常不要求改发布者”;正文保留其条件与取舍。
- 原始内容:The publishers have no knowledge of the subscribers, and subscribers are only aware of message types. Systems using the publish-subscribe pattern rely on implicit invocation; that is, the component publishing a message does not directly invoke any other component.