apache / apache/rocketmq-spring
Custom CGLIB RocketMQListener cannot be registered
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 943
- PR merge metrics
- No merged PRs in 30d
Description
The code below is unable to register the listener
```
@RocketMQMessageListener(consumerGroup = "", topic = "test")
static class Receiver implements RocketMQListener {
@Override
public void onMessage(Object message) {
}
}
@Bean
public Receiver customEnhancer() {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Receiver.class);
enhancer.setCallback((MethodInterceptor) (o, method, objects, methodProxy) -> null);
return (Receiver) enhancer.create();
}
```
version: 2.2.3
I reviewed the logic of `RocketMQMessageListenerBeanPostProcessor` and found several issues.
1. `AopUtils.getTargetClass` does not traverse nested proxies, whereas in version 4.x, `AopProxyUtils.ultimateTargetClass` is used instead.
2. if a custom CGLIB listener does not implement the SpringProxy interface, the correct target class cannot be obtained.


Contributor guide
No contributing guide indexed for this repository
Research direction
Start in RocketMQMessageListenerBeanPostProcessor and trace how it obtains the listener target class from a custom CGLIB proxy. Compare the use of AopUtils.getTargetClass with the reported AopProxyUtils.ultimateTargetClass behavior, including proxies that do not implement SpringProxy. Done means the provided custom Receiver can be registered successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100