Externalize Apache Camel Route Configurations for Spring Boot Apps
Time to get your Camel where it needs to go.
Join the DZone community and get the full member experience.Join For Free
In this article, we will discuss how we can externalize Apache Camel route configurations in a Spring Boot application using Spring profiles.
Below is a sample code of a Camel Route, which we will externalize.
Create application-dev.yml, application-tst.yml, application-prod.yml, and move the route configurations specific to the environments (dev, tst, prod) to the respective YML files.
Reference the values from the YML file in the code as below:
Create input directories specific to the environment as shown:
Edit the Run configuration of the Spring Boot application and provide the Active Profile as dev and start the application.
Notice that the file is deleted from the input directory of the dev folder and copied to the output directory as per the configuration.
Similarly, modify the Run configuration and set the Active profile as tst and prod. Notice that the file is deleted from the input directory of the respective environment folder and copied to the output directory as per the configuration and active profile set.
Opinions expressed by DZone contributors are their own.