{"id":19969119,"url":"https://github.com/pwright/camel-k-didact","last_synced_at":"2025-10-24T16:55:00.318Z","repository":{"id":103345848,"uuid":"315010062","full_name":"pwright/camel-k-didact","owner":"pwright","description":null,"archived":false,"fork":false,"pushed_at":"2020-11-22T10:22:57.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T17:48:36.566Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwright.png","metadata":{"files":{"readme":"readme.didact.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-22T10:22:53.000Z","updated_at":"2020-11-22T10:23:00.000Z","dependencies_parsed_at":"2023-07-07T19:00:19.138Z","dependency_job_id":null,"html_url":"https://github.com/pwright/camel-k-didact","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"openshift-integration/camel-k-example-basic","purl":"pkg:github/pwright/camel-k-didact","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwright%2Fcamel-k-didact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwright%2Fcamel-k-didact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwright%2Fcamel-k-didact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwright%2Fcamel-k-didact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwright","download_url":"https://codeload.github.com/pwright/camel-k-didact/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwright%2Fcamel-k-didact/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267414365,"owners_count":24083599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T02:48:48.620Z","updated_at":"2025-10-24T16:54:55.268Z","avatar_url":"https://github.com/pwright.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Camel K Basic Example\n \n![Camel K CI](https://github.com/openshift-integration/camel-k-example-basic/workflows/Camel%20K%20CI/badge.svg)\n\nThis example demonstrates how to get started with Camel K by showing you some of the most important \nfeatures that you should know before trying to develop more complex examples.\n\n## Before you begin\n\nMake sure you check-out this repository from git and open it with [VSCode](https://code.visualstudio.com/).\n\nInstructions are based on [VSCode Didact](https://github.com/redhat-developer/vscode-didact), so make sure it's installed\nfrom the VSCode extensions marketplace.\n\nFrom the VSCode UI, right-click on the `readme.didact.md` file and select \"Didact: Start Didact tutorial from File\". A new Didact tab will be opened in VS Code.\n\nMake sure you've opened this readme file with Didact before jumping to the next section.\n\n## Preparing the cluster\n\nThis example can be run on any OpenShift 4.3+ cluster or a local development instance (such as [CRC](https://github.com/code-ready/crc)). Ensure that you have a cluster available and login to it using the OpenShift `oc` command line tool.\n\nYou need to create a new project named `camel-basic` for running this example. This can be done directly from the OpenShift web console or by executing the command `oc new-project camel-basic` on a terminal window.\n\nYou need to install the Camel K operator in the `camel-basic` project. To do so, go to the OpenShift 4.x web console, login with a cluster admin account and use the OperatorHub menu item on the left to find and install **\"Red Hat Integration - Camel K\"**. You will be given the option to install it globally on the cluster or on a specific namespace.\nIf using a specific namespace, make sure you select the `camel-basic` project from the dropdown list.\nThis completes the installation of the Camel K operator (it may take a couple of minutes).\n\nWhen the operator is installed, from the OpenShift Help menu (\"?\") at the top of the WebConsole, you can access the \"Command Line Tools\" page, where you can download the **\"kamel\"** CLI, that is required for running this example. The CLI must be installed in your system path.\n\nRefer to the **\"Red Hat Integration - Camel K\"** documentation for a more detailed explanation of the installation steps for the operator and the CLI.\n\nYou can use the following section to check if your environment is configured properly.\n\n## Checking requirements\n\n\u003ca href='didact://?commandId=vscode.didact.validateAllRequirements' title='Validate all requirements!'\u003e\u003cbutton\u003eValidate all Requirements at Once!\u003c/button\u003e\u003c/a\u003e\n\n**OpenShift CLI (\"oc\")**\n\nThe OpenShift CLI tool (\"oc\") will be used to interact with the OpenShift cluster.\n\n[Check if the OpenShift CLI (\"oc\") is installed](didact://?commandId=vscode.didact.cliCommandSuccessful\u0026text=oc-requirements-status$$oc%20help\u0026completion=Checked%20oc%20tool%20availability \"Tests to see if `oc help` returns a 0 return code\"){.didact}\n\n*Status: unknown*{#oc-requirements-status}\n\n\n**Connection to an OpenShift cluster**\n\nYou need to connect to an OpenShift cluster in order to run the examples.\n\n[Check if you're connected to an OpenShift cluster](didact://?commandId=vscode.didact.requirementCheck\u0026text=cluster-requirements-status$$oc%20get%20project$$NAME\u0026completion=OpenShift%20is%20connected. \"Tests to see if `kamel version` returns a result\"){.didact}\n\n*Status: unknown*{#cluster-requirements-status}\n\n**Apache Camel K CLI (\"kamel\")**\n\nApart from the support provided by the VS Code extension, you also need the Apache Camel K CLI (\"kamel\") in order to \naccess all Camel K features.\n\n[Check if the Apache Camel K CLI (\"kamel\") is installed](didact://?commandId=vscode.didact.requirementCheck\u0026text=kamel-requirements-status$$kamel%20version$$Camel%20K%20Client\u0026completion=Apache%20Camel%20K%20CLI%20is%20available%20on%20this%20system. \"Tests to see if `kamel version` returns a result\"){.didact}\n\n*Status: unknown*{#kamel-requirements-status}\n\n### Optional Requirements\n\nThe following requirements are optional. They don't prevent the execution of the demo, but may make it easier to follow.\n\n**VS Code Extension Pack for Apache Camel**\n\nThe VS Code Extension Pack for Apache Camel by Red Hat provides a collection of useful tools for Apache Camel K developers,\nsuch as code completion and integrated lifecycle management. They are **recommended** for the tutorial, but they are **not**\nrequired.\n\nYou can install it from the VS Code Extensions marketplace.\n\n[Check if the VS Code Extension Pack for Apache Camel by Red Hat is installed](didact://?commandId=vscode.didact.extensionRequirementCheck\u0026text=extension-requirement-status$$redhat.apache-camel-extension-pack\u0026completion=Camel%20extension%20pack%20is%20available%20on%20this%20system. \"Checks the VS Code workspace to make sure the extension pack is installed\"){.didact}\n\n*Status: unknown*{#extension-requirement-status}\n\n\n## 1. Preparing the project\n\nWe'll connect to the `camel-basic` project and check the installation status.\n\nTo change project, open a terminal tab and type the following command:\n\n\n```\noc project camel-basic\n```\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$oc%20project%20camel-basic\u0026completion=New%20project%20creation. \"Opens a new terminal and sends the command above\"){.didact})\n\n\nWe should now check that the operator is installed. To do so, execute the following command on a terminal:\n\n\nUpon successful creation, you should ensure that the Camel K operator is installed:\n\n```\noc get csv\n```\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$oc%20get%20csv\u0026completion=Checking%20Cluster%20Service%20Versions. \"Opens a new terminal and sends the command above\"){.didact})\n\n\nWhen Camel K is installed, you should find an entry related to `red-hat-camel-k-operator` in phase `Succeeded`.\n\nYou can now proceed to the next section.\n\n## 2. Running a basic integration\n\nThis repository contains a simple Camel K integration that periodically prints \na \"Hello World...\" message.\n\nThe integration is all contained in a single file named `Basic.java` ([open](didact://?commandId=vscode.openFolder\u0026projectFilePath=Basic.java\u0026completion=Opened%20the%20Basic.java%20file \"Opens the Basic.java file\"){.didact}).\n\n\u003e **Note:** the `Basic.java` file contains a simple integration that uses the `timer` and `log` components.\n\u003e Dependency management is automatically handled by Camel K that imports all required libraries from the Camel\n\u003e catalog via code inspection. This means you can use all 300+ Camel components directly in your routes.\n\nWe're ready to run the integration on our `camel-basic` project in the cluster.\n\nUse the following command to run it in \"dev mode\", in order to see the logs in the integration terminal:\n\n```\nkamel run Basic.java --dev\n```\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$kamel%20run%20Basic.java%20--dev\u0026completion=Camel%20K%20basic%20integration%20run%20in%20dev%20mode. \"Opens a new terminal and sends the command above\"){.didact})\n\nIf everything is ok, after the build phase finishes, you should see the Camel integration running and continuously printing \"Hello World!...\" in the terminal window.\n\nWhen running in dev mode, you can change the integration code and let Camel K redeploy the changes automatically.\n\nTo try this feature,\n[open the `Basic.java` file](didact://?commandId=vscode.openFolder\u0026projectFilePath=Basic.java\u0026completion=Opened%20the%20Basic.java%20file \"Opens the Basic.java file\"){.didact} \nand change \"Hello World\" into \"Ciao Mondo\", then save the file.\nYou should see the new integration starting up in the terminal window and replacing the old one.\n\n[**To exit dev mode and terminate the execution**, just click here](didact://?commandId=vscode.didact.sendNamedTerminalCtrlC\u0026text=camelTerm\u0026completion=Camel%20K%20basic%20integration%20interrupted. \"Interrupt the current operation on the terminal\"){.didact} \nor hit `ctrl+c` on the terminal window.\n\n\u003e **Note:** When you terminate a \"dev mode\" execution, also the remote integration will be deleted. This gives the experience of a local program execution, but the integration is actually running in the remote cluster.\n\nTo keep the integration running and not linked to the terminal, you can run it without \"dev mode\", just run:\n\n```\nkamel run Basic.java\n```\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$kamel%20run%20Basic.java\u0026completion=Camel%20K%20basic%20integration%20run. \"Opens a new terminal and sends the command above\"){.didact})\n\n\n\nAfter executing the command, you should be able to see it among running integrations:\n\n```\noc get integrations\n```\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$oc%20get%20integrations\u0026completion=Getting%20running%20integrations. \"Opens a new terminal and sends the command above\"){.didact})\n\nAn integration named `basic` should be present in the list and it should be in status `Running`. There's also a `kamel get` command which is an alternative way to list all running integrations.\n\n\u003e **Note:** the first time you've run the integration, an IntegrationKit (basically, a container image) has been created for it and \n\u003e it took some time for this phase to finish. When you run the integration a second time, the existing IntegrationKit is reused \n\u003e (if possible) and the integration reaches the \"Running\" state much faster.\n\u003e\n\n\nEven if it's not running in dev mode, you can still see the logs of the integration using the following command:\n\n```\nkamel log basic\n```\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$kamel%20log%20basic\u0026completion=Show%20integration%20logs. \"Opens a new terminal and sends the command above\"){.didact})\n\nThe last parameter (\"basic\") is the name of the running integration for which you want to display the logs.\n\n[**Click here to terminate the log stream**](didact://?commandId=vscode.didact.sendNamedTerminalCtrlC\u0026text=camelTerm\u0026completion=Camel%20K%20basic%20integration%20interrupted. \"Interrupt the current operation on the terminal\"){.didact} \nor hit `ctrl+c` on the terminal window.\n\n\u003e **Note:** Your IDE may provide an \"Apache Camel K Integrations\" panel where you can see the list of running integrations and also open a window to display the logs.\n\n\n## 2. Applying configuration and routing\n\nThe second example is a bit more complex as it shows how to configure the integration using external properties and \nalso a simple content-based router.\n\nThe integration is contained in a file named `Routing.java` ([open](didact://?commandId=vscode.openFolder\u0026projectFilePath=Routing.java\u0026completion=Opened%20the%20Routing.java%20file \"Opens the Routing.java file\"){.didact}).\n\nThe routes use two configuration properties named `items` and `priority-marker` that should be provided using an external file such\nas the `routing.properties` ([open](didact://?commandId=vscode.openFolder\u0026projectFilePath=routing.properties\u0026completion=Opened%20the%20routing.properties%20file \"Opens the routing.properties file\"){.didact}).\n\nThe `Routing.java` file shows how to inject properties into the routes via property placeholders and also the usage of the `@PropertyInject` annotation.\n\nTo run the integration, we should link the integration to the property file providing configuration for it:\n\n```\nkamel run Routing.java --property-file routing.properties --dev\n```\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$kamel%20run%20Routing.java%20--property-file%20routing.properties%20--dev\u0026completion=Run%20Routing.java%20integration. \"Opens a new terminal and sends the command above\"){.didact})\n\nWait for the integration to be running (you should see the logs streaming in the terminal window).\n\nYou can now open both the [Routing.java](didact://?commandId=vscode.openFolder\u0026projectFilePath=Routing.java\u0026completion=Opened%20the%20Routing.java%20file \"Opens the Routing.java file\"){.didact} file or\nthe [routing.properties](didact://?commandId=vscode.openFolder\u0026projectFilePath=routing.properties\u0026completion=Opened%20the%20routing.properties%20file \"Opens the routing.properties file\"){.didact}\nfile, make some changes and see the integration redeployed.\nFor example, change the word `door` with `*door` to see it sent to the priority queue.\n\n[**Click here to exit dev mode and terminate the execution**](didact://?commandId=vscode.didact.sendNamedTerminalCtrlC\u0026text=camelTerm\u0026completion=Camel%20K%20basic%20integration%20interrupted. \"Interrupt the current operation on the terminal\"){.didact}, \nor hit `ctrl+c` on the terminal window.\n\nThis will also terminate the execution of the integration.\n\n## 3. Running integrations as Kubernetes CronJobs\n\nThe previous example can be automatically deployed as a Kubernetes CronJob if the delay between executions is changed into a value that can be expressed by a cron tab expression.\n\nFor example, you can change the first endpoint (`timer:java?period=3000`) into the following: `timer:java?period=60000` (1 minute between executions). [Open the Routing.java file](didact://?commandId=vscode.openFolder\u0026projectFilePath=Routing.java\u0026completion=Opened%20the%20Routing.java%20file \"Opens the Routing.java file\"){.didact} to apply the changes.\n\nNow you can run the integration again:\n\n```\nkamel run Routing.java --property-file routing.properties\n```\n\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$kamel%20run%20Routing.java%20--property-file%20routing.properties\u0026completion=Run%20Routing.java%20integration%20as%20CronJob. \"Opens a new terminal and sends the command above\"){.didact})\n\nNow you'll see that Camel K has materialized a cron job:\n\n```\noc get cronjob\n```\n\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$oc%20get%20cronjob\u0026completion=Get%20CronJobs. \"Opens a new terminal and sends the command above\"){.didact})\n\nYou'll find a Kubernetes CronJob named \"routing\".\n\nThe running behavior changes, because now there's no pod always running (beware you should not store data in memory when using the cronJob strategy).\n\nYou can see the pods starting and being destroyed by watching the namespace:\n\n```\noc get pod -w\n```\n\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$oc%20get%20pod%20-w\u0026completion=Watch%20Pods. \"Opens a new terminal and sends the command above\"){.didact})\n\n[**Click here to exit the current command**](didact://?commandId=vscode.didact.sendNamedTerminalCtrlC\u0026text=camelTerm\u0026completion=Camel%20K%20basic%20integration%20interrupted. \"Interrupt the current operation on the terminal\"){.didact},\nor hit `ctrl+c` on the terminal window.\n\nTo see the logs of each integration starting up, you can use the `kamel log` command:\n\n```\nkamel log routing\n```\n\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$kamel%20log%20routing\u0026completion=Watch%20integration%20logs. \"Opens a new terminal and sends the command above\"){.didact})\n\nYou should see every minute a JVM starting, executing a single operation and terminating.\n\n[**Click here to exit the current command**](didact://?commandId=vscode.didact.sendNamedTerminalCtrlC\u0026text=camelTerm\u0026completion=Camel%20K%20basic%20integration%20interrupted. \"Interrupt the current operation on the terminal\"){.didact},\nor hit `ctrl+c` on the terminal window.\n\nThe CronJob behavior is controlled via a Trait called `cron`. Traits are the main way to configure high level Camel K features, to \ncustomize how integrations are rendered.\n\nTo disable the cron feature and use the deployment strategy, you can run the integration with:\n\n```\nkamel run Routing.java --property-file routing.properties -t cron.enabled=false\n```\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$kamel%20run%20Routing.java%20--property-file%20routing.properties%20-t%20cron.enabled=false\u0026completion=Run%20Routing.java%20integration%20without%20CronJobs. \"Opens a new terminal and sends the command above\"){.didact})\n\nThis will disable the cron trait and restore the classic behavior (always running pod).\n\nYou should see it reflected in the logs (which will be printed every minute by the same JVM):\n\n```\nkamel log routing\n```\n\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$kamel%20log%20routing\u0026completion=Watch%20integration%20logs. \"Opens a new terminal and sends the command above\"){.didact})\n\n\n[**Click here to exit the current command**](didact://?commandId=vscode.didact.sendNamedTerminalCtrlC\u0026text=camelTerm\u0026completion=Camel%20K%20basic%20integration%20interrupted. \"Interrupt the current operation on the terminal\"){.didact},\nor hit `ctrl+c` on the terminal window.\n\nYou can continue to hack on the examples.\n\n## 4. Uninstall\n\nTo cleanup everything, execute the following command:\n\n```oc delete project camel-basic```\n\n([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString\u0026text=camelTerm$$oc%20delete%20project%20camel-basic\u0026completion=Removed%20the%20project%20from%20the%20cluster. \"Cleans up the cluster after running the example\"){.didact})\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwright%2Fcamel-k-didact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwright%2Fcamel-k-didact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwright%2Fcamel-k-didact/lists"}