Page
Create the Camel integration route and the REST API service
In the last lesson, you successfully defined your Camel project. Now let's create the Camel route.
What you need
- A workspace in Red Hat OpenShift Dev Spaces
- A no-cost Developer Sandbox for Red Hat OpenShift environment
What you will learn
- How to create an integration routeccess the Developer Sandbox
- How to create a REST API service
Create the Camel integration route
- From the Projects menu icon, select Karavan: Create Integration from the context menu (Figure 16).
- Enter
hello-world
as the integration name (Figure 17). - A new file with the name
hello-world-camel.yaml
has now been created. Inside the hello-world camel project, select the Routes tab, then Create route (Figure 18). - Under the Components tab, search for the word
direct
(Figure 19). - Click on the Direct icon. Enter
my-internal-route
to the internal route field (Figure 20). - Add more steps to the route. Click the + icon under the Direct Route (Figure 21).
- Choose the Routing tab, then search for the word
log
(Figure 22). - Configure the Log to print message
${body}
(Figure 23).
Create a simple REST API
- Click on the REST tab, then select Create service (Figure 24).
- Select Add method (Figure 25).
- Choose the Post method (Figure 26).
- Link the REST endpoints to the direct route. Inside the setting for the POST method, select To : direct:my-internal-route (Figure 27). This will route the incoming request to
my-internal-route
. - You can inspect the content of the Camel YAML file by double-clicking the
hello-world.camel.yaml
file in the project explorer. In Figure 28, the IDs are randomly generated.
Congratulations! You have successfully created a Camel route file. Now let's run and test it inside OpenShift.