Details
-
Wish
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.17.0
-
None
-
Any
-
Patch Available
-
Novice
-
Patch
Description
Kafka supports that one consumer is subcriber to multple topics. In their api when you start the consumer you MUST provide an Array of topics.
If we look in /java/org/apache/camel/component/kafka/KafkaConsumer.java
Currently this is the piece of code that starts the subscriber:
LOG.debug("Subscribing {} to topic {}", threadId, topicName);
consumer.subscribe(Arrays.asList(topicName));
just simply allowing the comma separated topic syntax and replacing one line of code (and the documentation) it would be working.
LOG.debug("Subscribing {} to topic {}", threadId, topicName); consumer.subscribe(Arrays.asList(topicName.split(",")));
Despite the same could be achieved by adding more consumers (rotues) this causes a significant amount of load (because of the commits) to kafka, so this really helps to improve performance.
the topic has been already marked as mandatory, so that should keep the nullpointer safe.
@UriParam @Metadata(required = "true")
private String topic;
thanks!