Issue
I have a camel-base application (spring with routes described in XML). I'd like it to be able to route the input messages to an unknown number of kafka topics (based on a configurable matching between filename patterns and topic names) so i cannot create a producer per pattern in advance in the xml file.
Ideally we would be to be able to set the topic in the message header, like the partition id...
Does anyone has a suggestion ?
Solution
Finally it is possible. I was refering to the wrong sources of the kafka consumer. In the most recent releases, it behaves exactly as I hoped it would.
topic = exchange.getIn().getHeader(KafkaConstants.TOPIC, topic, String.class);
So one has to set the KafkaCOnstants.TOPIC header in the message in order to dynamically chose the topic.
Answered By - Gege Grmbl
Answer Checked By - David Goodson (JavaFixing Volunteer)