Ask questionsMechanism of obtaining consumer settings through the groupId qualifier does not work for groups in the upper snake case pattern.
When defining a groupId in the upper snake case pattern (e.g: MY_GROUP_ID), KafkaConsumerProcessor is unable to obtain my customer's customized settings.
Up the apache kafka stack, creating a topic named my-products and an groupId MY_GROUP_ID.
Create a micronaut application with a consumer with the groupId MY_GROUP_ID.
kafka:
bootstrap:
servers: localhost:9092
consumers:
my-group-id:
value: io.confluent.kafka.serializers.KafkaJsonDeserializer
import io.micronaut.configuration.kafka.annotation.KafkaKey
import io.micronaut.configuration.kafka.annotation.KafkaListener
import io.micronaut.configuration.kafka.annotation.OffsetReset
import io.micronaut.configuration.kafka.annotation.Topic
@KafkaListener(
offsetReset = OffsetReset.EARLIEST,
groupId = "MY_GROUP_ID"
)
class ProductConsumer {
@Topic("my-products")
fun receive(@KafkaKey brand: String, product: Product) {
println("Got Product - ${product.name} by $brand")
}
}
data class Product(var name: String)
Custom consumer settings must be obtained. The consumer does not assume the io.confluent.kafka.serializers.KafkaJsonDeserializer value deserializer.
class: io.micronaut.configuration.kafka.processor.KafkaConsumerProcessor
method: public void process(BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method)
The code block below is contained in the class and method specified above. This is the mechanism that fetches the consumer custom configuration bean through the qualifier by name using the groupId. I believe that the error lies in this mechanism.
AbstractKafkaConsumerConfiguration consumerConfigurationDefaults =
beanContext.findBean(AbstractKafkaConsumerConfiguration.class, Qualifiers.byName(groupId))
.orElse(defaultConsumerConfiguration);
Custom consumer settings are not obtained.
https://github.com/NilMouraa/micronaut-kafka-issue-groupid
Answer
questions
NilMouraa
@graemerocher could you confirm if this is really a bug? Because if it is, I have a suggested solution for that. I can contribute with you.
Related questions
No questions were found.