RockteMQ-AI commented on issue #704:
URL: 
https://github.com/apache/rocketmq-spring/issues/704#issuecomment-5216242995

   **Issue Evaluation**
   
   Category: `question` | Status: **Answered**
   
   The `RocketMQMessageListener` annotation uses Spring's generic type 
resolution to determine the message type for deserialization. When you extend a 
base class and implement `RocketMQListener<T>`, the framework resolves the 
generic type from the concrete class, not the parent class.
   
   The issue in your code is that `BaseMQConsumer<T>` defines `onMessage(T 
message)` but the framework's `DefaultRocketMQListenerContainer` calls 
`RocketMQListener.onMessage()` directly — your parent class `onMessage(T)` 
shadows the interface method, causing the framework to bypass your 
context-setting logic.
   
   **Suggested approach:**
   - Instead of overriding `onMessage` in the parent class, use a custom 
`RocketMQListener` wrapper or AOP to inject the context before the actual 
listener processes the message.
   - Alternatively, handle context propagation in each consumer's `onMessage` 
implementation directly.
   
   This is a known limitation of the annotation-driven approach — it does not 
support inheritance-based message interception.
   
   ---
   *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: [email protected]

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

Reply via email to