Wiki

Clone wiki

devoops / Camel in Karaf

These notes apply installing Camel software to Karaf.

Remote Debugging With VSCode

https://code.visualstudio.com/docs/java/java-debugging

Start Karaf in remote debugging mode: karaf debug. Karaf default remote debugging port is 5005.

In VSCode configure remote debugging in suitable launch.json file:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug (Attach)",
            "request": "attach",
            "hostName": "localhost",
            "port": 5005
        }
    ]
}

In VSCode set breakpoint. Note that RouteBuilder.configure() methods are executed in the beginning when the JAR is deployed into Karaf so that's not the right place to set the breakpoints. Instead set them in some processors.

In VSCode: Run > Start Debugging (F5)

Installing Bundles In Local Development Environment

The bundles are started automatically when JAR is hot deployed (i.e. copied) to $KARAF/deploy directory.

Note the following when the bundles are installed with Karaf bundle:install command:

# the bundle is not started after installation by default
bundle:install mvn:/net.jani-hur/software/1.2.0
# but have to be explicitly started
bundle:start BUNDLE_ID
# install and start in one go
bundle:install --start mvn:/net.jani-hur/software/1.2.0

Unistallation:

Remove JAR from the $KARAF/deploy directory and:

# VERSION is optional
bundle:unistall ARTIFACT/VERSION

Updating Bundles In Local Development Environment

Update bundle from Maven with new version:

bundle:update <BUNDLE> mvn:/net.jani-hur/software/1.2.0

Investigating Bundles

bundle:headers <BUNDLE_NAME>
bundle:list -t 80
# required e.g. when the underlying dependencies needs to be resolved
bundle:refresh <BUNDLE_ID>
bundle:tree-show <BUNDLE_NAME>

Reset Karaf

Every now and then something goes wrong with the deployed software stack in Karaf. Then resetting the Karaf state and redeploying the stack fixes the issues.

  1. Stop Karaf
  2. Clean Karaf state by removing data directory: rm -rf $KARAF/data
  3. Remove hot deployed bundles: rm -f $KARAF/deploy/*.jar
  4. Start Karaf
  5. Redeploy your stuff

Restart Karaf

http://karaf.apache.org/manual/latest/#_restart

system:shutdown --force --reboot --clean-cache

Updated