Apache Camel K is a lightweight integration framework built on Apache Camel that runs natively on Kubernetes. Camel K is designed explicitly for serverless and microservices architectures and allows you to run an integration written in Camel DSL on your cloud.
Since Apache Camel K 1.0.0, it has been possible to specify the configuration options for starting an integration route using Apache Camel K Modeline. Just place a single comment line, // camel-k:
, at the top of your config file. Using this method allows you to specify a relatively complex integration project in a single file.
Until now, you could only access these configuration options through the command line. In this article, I introduce the new IDE support for Apache Camel K's Modeline configuration.
IDE support for Camel K Modeline
Thanks to the Apache Camel Language Server, you can now use an extension to add Camel K Modeline support to Visual Studio Code (VS Code), Eclipse desktop IDEs, and Eclipse Che.
The most useful Modeline options are available as completions. As shown in Figure 1, you can use the hover feature to view the completions and documentation for these features in VS Code.
Let's take a look at the completions and definitions for three key options available with the Modeline configuration: trait, dependency, and property.
Trait
The trait option proposes a completion for trait definition names and trait property names. Hovering over a trait name or property name displays its documentation. Figure 2 shows all of the trait completion options and a definition for one of them.
Figure 3 shows the completion options and a definition for a trait property.
Dependency
The dependency option suggests Camel artifact IDs and a template for other Maven-specified dependencies, as shown in Figure 4.
Property
The property option offers completions for Camel components and properties. You can use the hover feature to view the documentation for any selected element. Figure 5 shows the completion options for Camel components.
Even an integration that requires specific configurations can be contained in one file.
Figure 6 shows the completion options for a Camel property.
Overriding configuration options during development
Modeline's configuration includes the production configuration, which is a useful feature. During development, you can use additional or different parameters. You can manually launch the integration from the command line with the additional parameters. Doing this avoids modifying the source code.
If you want to launch the same configuration multiple times or share a specific configuration in development with colleagues, you can use VS Code tasks for this purpose. To do this, create a file in your project named tasks.json
and place it in a vscode
folder. You should then be able to use completions to access VS Code tasks that are specific to Camel K.
Here's an example:
{ "version": "2.0.0", "tasks": [ { "label": "Start in dev mode Camel K integration opened in active editor", "type": "camel-k", "dev": true, "file": "${file}", "problemMatcher": [] } ] }
If you enter the Camel K options that you need, completions provide the available options. When you call the "Start Apache Camel K integration" command, you can set the "use predefined task" option to launch your task with the configuration that you require.
Last updated: August 27, 2020