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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to