Skip to content

Unable to create multiple listeners using same class with KafkaListener annotation at class level #2451

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

Closed
bdbogjoe opened this issue Oct 20, 2022 · 1 comment · Fixed by #2453

Comments

@bdbogjoe
Copy link

There is issue in this line, we have to exclude the current bean if has no annotation in methods or in class level, should be something like :

if (annotatedMethods.isEmpty() && ! hasClassLevelListeners) {
          this.nonAnnotatedClasses.add(bean.getClass());
          this.logger.trace(() -> "No @KafkaListener annotations found on bean type: " + bean.getClass());
}

@bdbogjoe bdbogjoe changed the title Unable to create multiple listener using same class with KafkaListener annotation on class Unable to create multiple listeners using same class with KafkaListener annotation at class level Oct 20, 2022
@garyrussell
Copy link
Contributor

garyrussell commented Oct 20, 2022

Thanks for reporting.

Curious: How did you create an issue with no labels? The New Issue page does not have an option for that.

@garyrussell garyrussell self-assigned this Oct 20, 2022
@garyrussell garyrussell added this to the 3.0.0-RC2 milestone Oct 20, 2022
garyrussell added a commit to garyrussell/spring-kafka that referenced this issue Oct 20, 2022
Resolves https://github.com/spring-projects/spring-kafka/pulls

Classes with class level `@KafkaListener` were incorrectly added
to the `nonAnnotatedClasses` set, preventing multiple instances
of the same class to be registered as listeners.

**cherry-pick to 2.9.x, 2.8.x**
garyrussell added a commit to garyrussell/spring-kafka that referenced this issue Oct 20, 2022
Resolves spring-projects#2451

Classes with class level `@KafkaListener` were incorrectly added
to the `nonAnnotatedClasses` set, preventing multiple instances
of the same class to be registered as listeners.

**cherry-pick to 2.9.x, 2.8.x**
artembilan pushed a commit that referenced this issue Oct 21, 2022
Resolves #2451

Classes with class level `@KafkaListener` were incorrectly added
to the `nonAnnotatedClasses` set, preventing multiple instances
of the same class to be registered as listeners.

**cherry-pick to 2.9.x, 2.8.x**

* Fix CheckStyle.
artembilan pushed a commit that referenced this issue Oct 21, 2022
Resolves #2451

Classes with class level `@KafkaListener` were incorrectly added
to the `nonAnnotatedClasses` set, preventing multiple instances
of the same class to be registered as listeners.

**cherry-pick to 2.9.x, 2.8.x**

* Fix CheckStyle.
artembilan pushed a commit that referenced this issue Oct 21, 2022
Resolves #2451

Classes with class level `@KafkaListener` were incorrectly added
to the `nonAnnotatedClasses` set, preventing multiple instances
of the same class to be registered as listeners.

**cherry-pick to 2.9.x, 2.8.x**

* Fix CheckStyle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants