[Bug] RocketMQClientTemplate.receiveAsync closes the shared SimpleConsumer, breaking all subsequent operations
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 88/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- java
调研方向
从 rocketmq-v5-client-spring-boot 中的 RocketMQClientTemplate.receiveAsync(...) 开始,并将其与 receive() 和 destroy() 进行比较。使用一个记录操作的 fake consumer 运行所描述的回归测试;完成标准是共享 consumer 在 receiveAsync 之后仍可使用,并且其关闭由 destroy() 处理。
由索引模型根据 Issue 内容生成。
描述
Describe the Bug
RocketMQClientTemplate.receiveAsync(...) (rocketmq-v5-client-spring-boot) closes the shared SimpleConsumer right after starting an asynchronous receive:
SimpleConsumer simpleConsumer = this.getSimpleConsumer();
CompletableFuture<List<MessageView>> future = simpleConsumer.receiveAsync(maxMessageNum, invisibleDuration);
simpleConsumer.close(); // closes the shared singleton
return future;
The SimpleConsumer is a template-level singleton whose lifecycle belongs to the Spring bean's destroy() (which already closes it). Closing it here (1) disrupts the in-flight async receive it just started, and (2) permanently breaks the template: every subsequent receive/receiveAsync/ack/changeInvisibleDuration on the same template fails because the consumer is already closed. The synchronous receive() sibling does not close the consumer.
Steps to Reproduce
Call receiveAsync once, then any other consumer operation on the same template — it fails on the closed consumer.
What Did You Expect to See?
receiveAsync behaves like receive(): uses the shared consumer and leaves its lifecycle to destroy().
What Did You See Instead?
The shared consumer is closed after the first receiveAsync, breaking the async path and everything after it.
Additional Context
Fix incoming: remove the simpleConsumer.close() line; destroy() keeps its close. Includes a regression test with a recording fake consumer proving close is no longer invoked and the consumer stays usable.
- 主要语言
- Java
- 星标
- 2.3k
- 派生
- 941
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/rocketmq-spring 的其他 Issue
-
编译报错未关闭
难度 2/5 1-3 小时 新手友好度 72/100
apache/rocketmq-spring#692 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
apache/rocketmq-spring#678 · 2 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 82/100
apache/rocketmq-spring#670 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
apache/rocketmq-spring#609 · 3 条评论 ·
-
fix: AnnotationEnhancer chain silently discards all modifications in RocketMQMessageListenerBeanPostProcessor可能已有人在做 @lossend 于 137 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 25/100
apache/rocketmq-spring#776 · 8 条评论 ·
查看 apache/rocketmq-spring 的全部 Issue
相似的 Issue
-
bug/错误
难度 2/5 1-3 小时 新手友好度 64/100
FCL-Team/FoldCraftLauncher#1982 · 2 条评论 ·
维护者通常 1 天内回复
-
[BUG] micronaut-serde-oracle-jdbc-json brings a second OJDBC driver onto the runtime classpath可能已有人在做 @ZARAYACH 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
micronaut-projects/micronaut-serialization#1494 · 4 条评论 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 2 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 85/100
vitruv-tools/Vitruv-Change#600 ·
维护者通常 1 天内回复
-
code-health feature/sync OS/Android QA/Test-Plan-Specified QA/Yes
难度 2/5 1-3 小时 新手友好度 75/100
brave/brave-browser#60327 ·
维护者通常 1 天内回复