Camel Console

The camel-console is available from Camel 3.15 and newer versions.

The Camel Developer Console is intended assisting developers and can display various information about a running Camel application.

Camel comes with a set of consoles out of the box from camel-console and camel-catalog-console JARs. These consoles can display general information about the running JVM and the OS Environment, and of course Camel related information such as runtime metrics of the Camel routes, and a lot more.

Using Camel Console

The camel-console must be added to the classpath, and enabled either via

CamelContext context = ...
context.setDevConsole(true);

If using Camel Main / Spring Boot / Quarkus etc then the console can be enabled via configuration:

camel.main.dev-console-enabled = true

Dev Console and Camel JBang

The Developer Console is easily available when using Camel JBang, by the --console argument when running JBang.

For example to run a Camel route from foo.yaml and additional configurations from myapp.properties you can run as follows and have the console started and accessible from http://localhost:8080/dev

$ jbang camel@apache/camel run foo.yaml myapp.properties --console

Writing Custom Dev Consoles

To write a custom console, you need to add camel-console as dependency, as it comes with the base class AbstractDevConsole which we extend for our console.

@DevConsole("foo")
public class FooConsole extends AbstractDevConsole {

    public FooConsole() {
        super("acme", "foo", "Foolish", "A foolish console that outputs something");
    }

    @Override
    protected Object doCall(MediaType mediaType, Map<String, Object> options) {
        if (mediaType.TEXT.equals(mediaType)) {
            return "Some foolish text here";
        } else {
            // json structure
        }
    }

}

The class must be annotated with DevConsole and the unique id of the console (must be unique across all consoles). In the constructor the console specifies which group, id, display title, and description to use.

The doCall method is responsible for gathering the information the console should output.

Supported Media Types

A console can support any of, or all of the following types:

  • TEXT

  • JSON

The intention for TEXT is to be plain/text based that can be outputted in CLI and other low-level tools.

For JSON then the intention is the console outputs a json dataset with key/value pairs that holds the information, which can be displayed in a custom fashion such as in a web browser, or IDE tool such as VSCode.

Maven Configuration

To make Camel able to discover custom dev consoles, then the came-component-maven-plugin must be used, such as:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-component-maven-plugin</artifactId>
            <version>${camel-version}</version>
            <executions>
                <execution>
                    <id>generate</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <phase>process-classes</phase>
                </execution>
                <execution>
                    <id>generate-postcompile</id>
                    <goals>
                        <goal>generate-postcompile</goal>
                    </goals>
                    <phase>prepare-package</phase>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                        <goal>add-resource</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/generated/java</source>
                        </sources>
                        <resources>
                            <resource>
                                <directory>src/generated/resources</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>