I am new to Apache Camel, and trying to figure out the best way to configure switching routes based on certain values.
What I do at the moment is:
- Retrieve the data from Kafka
- Then, process it in a controller, and put a certain value in a header (here I feel something is not right)
- Process the controller output header and check the value
- Choose the route to go based on the header's value
this.from("direct:kafka.scenario.update").routeId("publish.scenario.kafka.controller.route")
.log(LoggingLevel.INFO, "Send Scenario update 2 Kafka Route").process(this.publishScenarioUpdateKafkaController).choice()
.when( simple( "${out.header.updateType} == '" + ChangeType.UPDATE + "'" ))
.process(this.publishVmsUpdateKafkaController)
.to(dataRefScenarioUpdateProducerRoute)
.when( simple( "${out.header.updateType} == '" + ChangeType.CREATE + "'" ))
.process(this.publishVmsUpdateKafkaController)
.to(dataRefScenarioCreateProducerRoute)
.when( simple( "${out.header.updateType} == '" + ChangeType.DELETE + "'" ))
.process(this.publishVmsUpdateKafkaController)
.to(dataRefMessageDeleteProducerRoute);
Any thoughts?