Hello and welcome to another short Camel development series. This time we will look at a real life use case and how we can run Camel inside spring boot. We will also see how Camel can be used not just for enterprise integration but as a useful tool in your toolbox.
In our case we work daily with IBM Integration Bus. We needed an automatic and easy way to generate on a daily manner a list of execution groups, deployed applications and restapis together with some properties. The aim was to post this json message to a logic app on Azure which then generate a Sharepoint table where we could see what is available on a specific environment and when it was last deployed.
To go straight to the code https://github.com/SoucianceEqdamRashti/Integration/tree/master/artefacts . Note there are probably lots that can be improved and I have not included any tests and the logging is basic to say the least but the overall functionality should work. You can off course extend it and customize it your IIB environment and needs. The advantage of doing it this way is that you don’t need to mess with mqsi commands and mqsi profiles. You use the API to get all the data. This means you can incorporate it as part of your CI/CD process or do it remotely. The main problem with the IIB API v10 is that there is no way to get all the properties of all deployed artefacts at once. You have to first get a list of execution groups, then for each execution group get a list of apps or restapis and then for each such component get its properties. Finally combine the whole thing into a complete json message.
You basically start the spring boot app by running the following command:
java -jar iibartefacts.jar -Dcom.sun.net.ssl.checkRevocation=false -Dspring.config.location=<path-to-your-application-props-file> -Diib.endpoint=<url-to-your-iib-endpoint-including-port> -Denvironment=<specify-environment>
Here we are providing a few jvm properties:
- We disable ssl validation. If you need to validate to off course remove this parameter. I don’t in our case so that’s why its there.
- I provide the path to my spring boot application.properties file. I don’t want it to be bundled in my fat jar so here I provide a full path to its location.
- The parameter iib.endpoint is a complete url to your iib endpoint. It could be test-myiib.com:4414.
- Finally the parameter environment is required because in the json message we provide the type of the environment i.e. if its test, preprod or prod. If you don’t need this then you need to change the code as well.
The spring boot app uses the in memory database H2 to store the extracted data (list of execution groups etc). The H2 config is located in the application.properties file and you can view the schema.sql file to see how I configured the table. Should you need further properties simply add additional columns.
Then there is the straight forward SpringApplication main class which starts the main route. This route simply kicks off everything and calls the other routes. Finally the json message is generated and saved to a file. If you need to post the json somewhere else then simply change the endpoint.
The logging and error handling could be improved, as well as some unit tests but this was basically an attempt to use spring boot and camel to create a tool that would complement an existing an platform. It took me roughly 1.5 day working to get to work properly and tidy up.
If you run into any issues or have suggestions let me know.