Apache Camel F2F tooling hackathon (go back)
The goal of this lab is to create a simple Camel route in VS Code leveraging the Extension pack for Apache Camel by Red Hat.
- Install VS code.
- Install the Extension pack for Apache Camel by Red Hat in VS Code.
- Install JBang CLI.
-
Open the command palette by pressing
F1
orCtrl + Shift + P
(Windows/Linux) orCmd + Shift + P
(Mac). -
Type
Camel: Create a Camel Route using YAML DSL
and pressEnter
.
- Type
test
to be the file name and pressEnter
.
- The new file will be opened with the Kaoto editor.
- Execute the route by pressing the
Run
button in the top right corner of the editor.
- The route will be executed and the output will be shown in the terminal.
- In the route, click on the
setBody
component to open the configuration panel
- By default, only
Required
properties are shown. Click on theAll
button to show all properties.
- Change the
expression
property toHello from the tooling hackathon!
.
- Save the file by pressing
Ctrl + S
(Windows/Linux) orCmd + S
(Mac) and notice how the route is restarted automatically.
- Let's replace the
log
EIP (Enterprise Integration Pattern) with alog
component. Right-click on thelog
EIP, and selectReplace
in the context menu.
- Write
log
in the search box and select theLog Data
component.
- Save the file by pressing
Ctrl + S
(Windows/Linux) orCmd + S
(Mac) and notice how the route is restarted and now it shows theExchange
information.
- Let's configure the
Log
component to show theExchange
headers and pretty print the information. Click on theLog
component to open the configuration panel. In the search box, typeheader
and enable theshowHeaders
property.
- Save the file by pressing
Ctrl + S
(Windows/Linux) orCmd + S
(Mac) and notice how the route is restarted and now it shows the emptyExchange
headers map.
- Let's add a header to the
Exchange
. Right-click on thelog
component to open the context menu and selectPrepend
to add a new EIP before thelog
component.
- Write
setHeader
in the search box and select theSetHeader
EIP.
- Notice how the
SetHeader
EIP is added before theLog
component and it shows a yellow warning indicating that required properties are missing. Click on theSetHeader
EIP to open the configuration panel.
- Click on
All
, then in theExpression
field, type${messageHistory}
. Note that the list of available variables depends on the chosen language, in this case with Simple expression you can look at Camel documentation for Simple language.
- In the
Name
field, typemessageHistory
.
- Save the file by pressing
Ctrl + S
(Windows/Linux) orCmd + S
(Mac) and notice how the route is restarted and now it shows theExchange
headers map with themessageHistory
header.
- Congratulations! You have developed a simple Camel route in VS Code.