Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom CGLIB RocketMQListener cannot be registered #532

Open
lvxiao1 opened this issue Feb 28, 2023 · 0 comments · May be fixed by #533
Open

Custom CGLIB RocketMQListener cannot be registered #532

lvxiao1 opened this issue Feb 28, 2023 · 0 comments · May be fixed by #533

Comments

@lvxiao1
Copy link

lvxiao1 commented Feb 28, 2023

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.
    image
    image
@lvxiao1 lvxiao1 linked a pull request Feb 28, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant