Service Templates Demo
Service Templates are reusable, parameterized blueprints for creating Service Catalogs. Instead of writing Camel routes from scratch, you pick a template, fill in the parameters, and deploy. This demo shows how to use built-in templates and create your own.
What You Will Need
- Wanaku running via
wanaku start local - Familiarity with Service Catalogs
Part 1: Using a Built-in Template
Step 1: List Available Templates
wanaku service template listYou should see templates like kafka-tool, jms-tool, github-pullrequest-source-tool, mail-sink-tool, rabbitmq-tool, among others. Each entry shows the template name, description, and the properties it requires.
Step 2: Instantiate the Template
Instantiate the kafka-tool template, passing the required properties:
wanaku service template instantiate --name=kafka-tool \
--property=kafka.brokers=localhost:9092 \
--property=kafka.request.topic=ai.requests \
--property=kafka.response.topic=ai.responses \
--property=kafka.reply.timeout-ms=30000 \
--property=kafka.response.group-id=wanaku-demo-groupStep 3: Deploy the Instantiated Catalog
Get the deployment instructions for the instantiated catalog:
wanaku service instructions --name kafka-tool --model localThis prints the command to launch the Camel Integration Capability. The output looks like:
Deployment instructions for 'kafka-tool' (camel-integration-capability, local)
--- System: kafka ---
java -jar camel-integration-capability-main-*-jar-with-dependencies.jar \
--registration-url <registration-url> \
--registration-announce-address localhost \
--grpc-port <grpc-port> \
--name kafka \
--service-catalog kafka-tool \
--service-catalog-system kafka \
--client-id wanaku-service \
--fail-fastRun that command in a separate terminal, filling in the placeholders. See the Introduction to Capabilities guide for details on downloading and running the Camel Integration Capability.
Step 4: Verify
wanaku tools list | grep kafkaYou should see a kafka_request_reply tool (or similar, depending on the template version).
Note: Actually testing the Kafka tool requires a running Kafka broker. The
start-local-kafka.shscript in this directory can help you start one quickly.
Part 2: Creating a Custom Template
Let's create a weather template that can be reused with different API keys and locations.
Step 1: Create the Template Directory
mkdir -p /tmp/weather-template/weather
cd /tmp/weather-templateStep 2: Create index.properties
catalog.name=weather-template
catalog.description=Weather information service template
catalog.services=weather
catalog.routes.weather=weather/weather.camel.yaml
catalog.rules.weather=weather/weather.rules.yaml
catalog.dependencies.weather=weather/weather.dependencies.txt
catalog.properties.weather=weather/service.propertiesStep 3: Create service.properties
This is where you define the parameterized placeholders:
weather.api.key={{weather.api.key}}
weather.location={{weather.location}}
weather.units={{weather.units}}Step 4: Create the Camel Route
Create weather/weather.camel.yaml:
- route:
id: get-weather
description: Get current weather for the configured location
from:
uri: direct:wanaku
steps:
- setHeader:
name: CamelHttpMethod
constant: GET
- log:
message: "Fetching weather for location: {{weather.location}}"
- to:
uri: "https://api.openweathermap.org/data/2.5/weather?q={{weather.location}}&appid={{weather.api.key}}&units={{weather.units}}"
- log:
message: "Weather data: ${body}"Step 5: Add Dependencies
Create weather/weather.dependencies.txt:
org.apache.camel:camel-http:4.18.2
org.apache.camel:camel-jackson:4.18.2Step 6: Generate Rules and Deploy
cd /tmp
wanaku service expose --path=weather-template
wanaku service package --path=weather-template -o weather-template.zip
wanaku service template deploy --file=weather-template.zip --host=http://localhost:8080Step 7: Instantiate Your Template
Instantiate the template you just deployed, providing the required property values:
wanaku service template instantiate --name=weather-template \
--property=weather.api.key=YOUR_API_KEY \
--property=weather.location="New York" \
--property=weather.units=metricNote: You'll need a free API key from OpenWeatherMap to use this template. Replace
YOUR_API_KEYwith your actual key.
What's Next?
- Wanaku on the Cloud (demo 3.01) — deploy Wanaku on OpenShift with Keycloak authentication and the Wanaku Operator
Troubleshooting
Template instantiation fails with "missing property"
- Double-check property names match exactly (case-sensitive)
- Ensure all required properties are provided via
--propertyflags - Check the template's
service.propertiesfile for required placeholders
If you find a bug, please report it.