You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "wang-jiahua (via GitHub)" <gi...@apache.org> on 2026/09/03 10:23:17 UTC

[I] [Bug] RocketMQClientTemplate.receiveAsync closes the shared SimpleConsumer, breaking all subsequent operations [rocketmq-spring]

wang-jiahua opened a new issue, #780:
URL: https://github.com/apache/rocketmq-spring/issues/780

   ### Describe the Bug
   
   `RocketMQClientTemplate.receiveAsync(...)` (rocketmq-v5-client-spring-boot) closes the **shared** `SimpleConsumer` right after starting an asynchronous receive:
   
   ```java
   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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] RocketMQClientTemplate.receiveAsync closes the shared SimpleConsumer, breaking all subsequent operations [rocketmq-spring]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #780:
URL: https://github.com/apache/rocketmq-spring/issues/780#issuecomment-5655091605

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The issue is valid. `RocketMQClientTemplate.receiveAsync` closes the shared `SimpleConsumer` immediately after initiating an async receive, which breaks all subsequent operations that depend on that consumer instance.
   
   The `close()` call should be removed — the shared `SimpleConsumer` lifecycle should be managed by the template/container, not by individual receive operations. This is a clear lifecycle management bug.
   
   An automated fix proposal may be generated. Reply `/approve` to proceed with PR generation.
   
   ---
   *Automated evaluation by github-manager*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] RocketMQClientTemplate.receiveAsync closes the shared SimpleConsumer, breaking all subsequent operations [rocketmq-spring]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #780:
URL: https://github.com/apache/rocketmq-spring/issues/780#issuecomment-5524744240

   **Issue Evaluation**
   
   Category: `bug` | Status: **Confirmed**
   
   The reported issue has been verified against the current codebase.
   
   **Root Cause:** In `RocketMQClientTemplate.receiveAsync()` (line 373–377), `simpleConsumer.close()` is called immediately after `simpleConsumer.receiveAsync(...)`, closing the shared singleton `SimpleConsumer`. This:
   1. Disrupts the in-flight async receive operation that was just started
   2. Permanently breaks the template — all subsequent `receive`/`receiveAsync`/`ack`/`changeInvisibleDuration` calls fail because the consumer is already closed
   
   The synchronous sibling `receive()` (line 367–370) does **not** close the consumer, confirming this is an erroneous addition.
   
   **Impact:** Critical — calling `receiveAsync()` once renders the entire template unusable. The `SimpleConsumer` lifecycle should be managed by the Spring bean's `destroy()` method, not by individual operations.
   
   **Severity:** High — single call breaks all subsequent consumer operations on the template.
   
   **Suggested Fix:** Remove the `simpleConsumer.close()` call from `receiveAsync()`. The consumer lifecycle is already properly managed by the Spring bean destroy callback.
   
   An automated fix proposal can be generated. Reply `/approve` to proceed with PR generation.
   
   ---
   *Automated evaluation by RockteMQ-AI*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] RocketMQClientTemplate.receiveAsync closes the shared SimpleConsumer, breaking all subsequent operations [rocketmq-spring]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #780:
URL: https://github.com/apache/rocketmq-spring/issues/780#issuecomment-5529963158

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported issue has been verified. `RocketMQClientTemplate.receiveAsync()` incorrectly closes the shared `SimpleConsumer` singleton after initiating an async receive, which:
   1. Disrupts the in-flight async operation
   2. Permanently breaks the template for all subsequent operations
   
   The synchronous `receive()` method does not exhibit this behavior, confirming this is a lifecycle management bug.
   
   **Root Cause:** Premature `simpleConsumer.close()` call in the async path
   **Impact:** All consumer operations fail after first `receiveAsync()` call
   **Severity:** High - breaks core functionality
   
   A fix is straightforward: remove the `close()` call and let the Spring bean lifecycle manage it via `destroy()`.
   
   ---
   *Automated evaluation by RockteMQ-AI*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org