Getting Started¶
Get up and running with Forage in minutes.
Prerequisites¶
- Java 17 or later
- Apache Camel 4.18.1+ with Camel JBang installed
Install the Forage Plugin¶
Forage extends Camel JBang with the forage plugin. Install it once:
Verify the installation:
Once installed, the standard camel run and camel export commands automatically discover Forage dependencies from your properties files — no --dep flags needed. The plugin also adds camel forage config and camel forage datasource subcommands for configuration management.
Your First Route¶
Let's build a simple route that queries a PostgreSQL database.
1. Start a database¶
Create a test table:
docker exec -i camel-postgres psql -U postgres -c \
"CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT); \
INSERT INTO users (name) VALUES ('Alice'), ('Bob');"
2. Create the route¶
Create a file called route.camel.yaml:
- route:
from:
uri: timer:query
parameters:
period: "5000"
steps:
- to:
uri: sql
parameters:
query: select * from users
dataSource: "#myDatabase"
- log:
message: "Users: ${body}"
3. Configure the datasource¶
Create a file called application.properties:
forage.myDatabase.jdbc.db.kind=postgresql
forage.myDatabase.jdbc.url=jdbc:postgresql://localhost:5432/test
forage.myDatabase.jdbc.username=test
forage.myDatabase.jdbc.password=test
The myDatabase prefix becomes the bean name — Forage registers a pooled datasource as #myDatabase in the Camel registry. No Java code, no bean definitions.
4. Run it¶
You should see the query results logged every 5 seconds:
5. Export to production¶
When you're ready to deploy, export to Spring Boot or Quarkus:
What's Next?¶
- Explore the Core Concepts to understand how Forage works
- Browse working Examples covering JDBC, JMS, transactions, and AI agents
- See all available Modules for a full list of supported technologies