Repository navigation
Feature/issue 222 async event ordered 8x - #223
Merged
Merged
Conversation
同一 traceId 的异步事件此前被投放固定线程池后并发消费,投放顺序不等于 执行顺序,导致订阅方乱序或并发执行。改为按 traceId 链式串行分发: - 新增 OrderedAsyncDispatcher,基于 CompletableFuture 队尾链式追加任务, 同 trace 串行、跨 trace 并行,任务完成后清理队尾条目避免内存泄漏; - 异常任务被隔离,不中断同 trace 后续任务; - EventTraceContext 的 traceKeys/eventKeyState 改为并发容器,消除并发读写隐患; - 新增配置 codingapi.framework.event-async-ordered(默认 true),关闭可退回原并发行为; - 补充串行/并行/异常/清理/开关单测与 handler 集成测试(Java 8 适配)。 Ref #222
回应 issue #222 复核反馈,补齐上一轮遗漏的端到端缺口: - trace 绑定到事务边界:事务内连续 push 共享同一 traceId,afterCompletion 解绑避免连接池线程复用串 trace;新增 EventPusher.push(IEvent...) 批量 API 显式声明同批次;防环检测收窄为仅 handler 内嵌套 push,避免批量同类误判; - EventStackContext 换并发容器,返回快照不暴露内部 list; - 默认 handler 改用 @TransactionalEventListener(AFTER_COMMIT, fallbackExecution), 提交后分发保证订阅方可见性;去掉 dispatch 的 synchronized; - 统一异常语义:ordered 两条路径均 wrap,循环异常明确日志; - 配置名改为 codingapi.framework.event.async.ordered; - 删除绕过 push 的旧测试,新增经 EventPusher.push 的端到端测试 (事务共享 trace、严格串行、批量同类不误判),Java 8 适配。 Ref #222
- 事务 trace 绑定守卫改为 isActualTransactionActive && isSynchronizationActive, registerSynchronization 加 try/catch 回退,避免 SYNCHRONIZATION_NEVER 事务管理器抛异常打断业务; - 删除只写不读的 traceKeys 集合,减少无界集合心智负担; - SpringTransactionEventHandler 合并为 SpringDefaultEventHandler 的 deprecated 兼容别名, 消除重复的 dispatch 实现,transaction.enable 不再产生行为差异; - 补事务回滚不投递的端到端回归用例; - 文档补充顺序边界:无事务独立 push 不保证顺序、串行维度为 trace(跨并发事务无保证), 说明批量 API、新配置项,标注旧配置废弃。 Ref #222
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
Does this pull request fix one issue?
Describe how you did it
Describe how to verify it
Special notes for reviews