Skip to content

Camel JBang

The Forage plugin for Camel JBang provides dependency resolution, property validation, hot reload, and export to production runtimes.

Installation

camel plugin add forage --gav io.kaoto.forage:camel-jbang-plugin-forage:1.2-SNAPSHOT

Running Routes

camel run *

The * glob picks up all route files and properties in the current directory. You can also specify files explicitly:

camel run route.camel.yaml application.properties

With the Forage plugin installed, the standard camel run command automatically resolves all required Forage dependencies based on your configuration — no --dep flags needed.

Property Validation

The plugin validates your Forage properties against the catalog before running. This catches configuration errors early.

Typo Detection

# Typo in property name
forage.myDb.jdbc.usernam=admin
[UNKNOWN_PROPERTY] in application.properties
  Property: forage.myDb.jdbc.usernam
  Unknown property 'usernam' for factory 'jdbc'. Did you mean 'username'?

Invalid Bean Values

# Invalid database kind
forage.myDb.jdbc.db.kind=postgresqll
[INVALID_BEAN_VALUE] in application.properties
  Property: forage.myDb.jdbc.db.kind
  Unknown database 'postgresqll'. Did you mean 'postgresql'?
  Valid options: postgresql, mysql, mariadb, db2, h2, oracle

Unknown Properties

# Property that doesn't exist
forage.myDb.jdbc.invalid.property=value
[UNKNOWN_PROPERTY] in application.properties
  Property: forage.myDb.jdbc.invalid.property
  Unknown property 'invalid.property' for factory 'jdbc'

Hot Reload

In dev mode, Forage watches .properties files for changes and automatically recreates beans without restarting:

camel run --dev *

When you edit a properties file, Forage:

  1. Clears the configuration cache
  2. Destroys old beans
  3. Creates new beans with updated configuration
  4. Resets Camel components so routes pick up the new beans

What Can Be Hot-Reloaded

  • API keys, connection URLs, model names
  • Connection pool sizes, timeouts
  • Any forage.* property value

What Requires a Restart

  • Provider type changes — e.g., changing db.kind from postgresql to mysql (requires different JARs)
  • Adding new factory types — e.g., adding JDBC when only AI was configured
  • Environment variable changes — the file watcher monitors .properties files only

Exporting to Production

Export your project to Spring Boot or Quarkus with all Forage dependencies included:

camel export --runtime=spring-boot --directory=./my-app
camel export --runtime=quarkus --directory=./my-app

Testing Connections

Verify datasource connectivity without starting routes:

camel forage datasource test-connection

Configuration Commands

Read Forage configuration and output bean definitions as JSON:

camel forage config read

Write configuration from JSON input:

camel forage config write --input '{"forage.myDb.jdbc.url":"jdbc:postgresql://localhost:5432/mydb"}'