Repository navigation
Conversation
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.
Which Issue(s) This PR Fixes
Fixes #1392
Brief Description
同步
MessageListener将方法返回与消费结果绑定:把处理任务转交其他线程后立即返回 SUCCESS,会提前推进 ACK;等待异步任务结束再返回,又会占用消费线程。本 PR 新增可选的AsyncMessageListener.consumeAsync(MessageView),让返回的CompletionStage<ConsumeResult>表示实际处理结果。处理与确认链路:
同步与异步 listener 按最后一次 setter 调用选择。原同步 API 保留,新接口通过公开 Builder 接入,无需额外 Consumer 子类或反射适配。
运行期调参与异步消费共用同一套准入逻辑:
PushConsumer.updateRuntimeTuning(cacheCount, cacheBytes, consumptionConcurrency)在原实例上更新缓存限额和处理并发。扩容允许更多排队任务进入;缩容不打断已有任务,后续任务等待活跃数量降到新限额以下。所有参数先校验,非法参数不会部分生效。平台线程、虚拟线程及其回退模式均支持这一行为。这两项能力共同解决“任务转交后如何限制未完成处理,并在运行中调整准入”的问题,因此放在同一份 PR 中。此 PR 可独立合并,不依赖内部线程池配置 PR。
完成与续期边界:
autoRenew=true协议及服务端时长限制。close()等待 stage 终结,应用应确保其最终完成,并在 Consumer 关闭后再关闭应用执行器。包含公开 API、接入示例、README 及 JDK 21 CI 覆盖。
How Did You Test This Change?
在此 PR 的独立分支、macOS arm64 上验证:
mvn -B package成功,364 项测试,0 失败、0 错误,1 项上游已有测试跳过;Checkstyle、SpotBugs 及普通/shaded JAR 构建通过。JDK 21 复现命令:
测试覆盖 stage 延迟完成、成功/失败/异常/取消/null、执行器拒绝、延迟调度、未完成 stage 的并发限制、活跃任务扩缩容、参数校验、FIFO 顺序、接收交接和确认排空。
新增 3 项本地 gRPC 集成测试,通过公开 Builder 启动客户端,验证未完成前无 ACK、完成后单次 ACK、失败后的 ChangeInvisibleDuration 重试及 close 等待在途 ACK 响应。服务仅绑定
127.0.0.1;未连接真实 Broker,也不将这些测试解释为生产吞吐或续期上限验证。JDK 21 使用上游现有 Byte Buddy 的测试兼容选项
-Dnet.bytebuddy.experimental=true。