Skip to content

Latest commit

 

History

History
236 lines (167 loc) · 5.55 KB

walkthrough.adoc

File metadata and controls

236 lines (167 loc) · 5.55 KB

Camel X - Lab1

Explore, build, test and deploy a Camel X demo application using the Developer Sandbox and OpenShift Dev Spaces.

This hands-on lab is based on the following blog article in Red Hat Developers:


Assuming you have followed the article’s instructions, you should be all set to get hands-on with Camel X in the OpenShift Dev Spaces workspace.

For illustration purposes, the picture below shows what the integration end-to-end flow looks like.

00 demo end2end

A client invokes an OpenApi service. A Camel route attends the call, translates the JSON input into XML and calls a backend service to obtain an XML response, then it’s translated back to JSON before responding to the original service call.


Explore the source code

The Camel source file api-simple.xml defines the entire end-to-end processing logic, which you can find in your project explorer under the path:

  • some/path/camel/api-simple.xml


Run the stub in your terminal

The stub acts as the backend service that provides the XML data we need to fetch.

  1. Let’s first run the stub

    Copy and paste the following command in your terminal to place yourself in the stub’s Camel Spring Boot project:

    cd camelsb/stubs/end1

    Then, copy/paste the following command to start the stub in the terminal:

    mvn -Dspring-boot.run.profiles=dev -s configuration/settings.xml


    Copy/paste the following cURL command to obtain a response from the stub:

    curl -s \
    -H "content-type: application/xml" \
    -d '' \
    http://localhost:9000/camel/subscriber/details \
    | bat -pP -lxml


Did you obtain the same XML message as shown above?

You’ve successfully tested the stub !!

Inspect in the stub logs to investigate the possible causes of failure.

Run the service in your terminal

The main Camel service exposes a JSON REST API and integrates with the XML backend service (the stub).


  1. Run the main service

    Copy and paste the following command in your terminal to place yourself in the main Camel Spring Boot project:

    cd /projects/devsandbox-camel/camelsb/level1simple/

    Then, copy/paste the following command to start the stub in the terminal:

    mvn -Dspring-boot.run.profiles=dev -s configuration/settings.xml


Did you obtain the same JSON response as the one shown above?

You’ve successfully tested the main service !!

Inspect in the stub logs to investigate possible causes of failure.

Deploy and test the stub

The stub acts as the backend service that provides the XML data we need to fetch.


  1. Test the stub

    Copy/paste the following cURL command to obtain a response from the stub:

    curl -s \
    -H "content-type: application/xml" \
    -d '' \
    http://end1:8080/camel/subscriber/details \
    | bat -pP -lxml
    Note
    The cURL command above now points to the newly deployed pod, with its service end1 listening on port 8080.
    Note
    The command also includes a pipe to colorise the XML output for better reading.


Did you obtain the same XML message as shown above?

You’ve successfully tested the stub deployed in the sandbox !!

Inspect in the stub logs to investigate possible causes of failure.

Deploy and test the main service

With the stub already deployed, we just need to deploy the service which will integrate with the stub running under the same namespace.


  1. Deploy the service

    Ensure you run the commands below from the terminal located in the path of your main service project.

    You can now copy and paste the following command in your terminal to trigger the deployment:

    mvn oc:deploy -Popenshift -s configuration/settings.xml


Did you obtain the same JSON response as shown above?

You’ve successfully invoked the simple service as an external client !!

Inspect in the stub logs to investigate possible causes of failure.


Clean up your namespace

When you’re done playing in the Developer Sandbox, you can clean up your Sandbox namespace by un-deploying your Camel simple service and stub end1 using the following Maven oc:undeploy command for both:

mvn oc:undeploy -Popenshift -s configuration/settings.xml

Executing the command above for both services should leave your topology view clean from routes, services, and other Kubernetes artifacts in your namespace.


Is your namespace clean from artifacts?

You’ve successfully cleaned up your namespace !!

Inspect in the stub logs to investigate possible causes of failure.