-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add a way to pass objects as values for @KafkaListerner properties #3580
Comments
Instead of directly passing the bean reference in the @KafkaListener properties, you can define a custom property resolver that maps a string property to the desired bean.
} |
Hi @Ravikiran26, thank you for you answer. I am aware that there are workarounds like this. |
Let me try to summarize the concern! From here I believe your request is to improve that And even if we can use a
Pay attention to the
where:
So, if value is not a Might be the case that we have to revise the logic from Please, confirm that we are on the same page. |
Expected Behavior
Have a way to pass objects or bean references as values for
@KafkaListener
properties (KafkaConsumer properties).For example to use the bean reference
#{__listener.filterPredicate}
as a configuration property for a kafka-client ConsumerInterceptor. See alsoWiring Spring Beans into Producer/Consumer Interceptors
https://docs.spring.io/spring-kafka/reference/kafka/interceptors.html
Current Behavior
KafkaListener properties only accept string values. See javadoc
SpEL expressions must resolve to a String, a @{link String[]} or a Collection<String>
Attempting to use a bean reference will result in an exception with the message.
No converter found capable of converting from type [eu.europa.ec.test.kafka.FilterRecordPredicate] to type [java.lang.String]
Context
Currently we use either a consumer factory customizer (In case it applies to all consumers) or custom consumer factory beans (if it is consumer specific). Especially in the latter case we prefer to use the default spring boot consumer factory and annotations on the kafka listener.
The text was updated successfully, but these errors were encountered: