Overview
The pfx-resources component loads static files from the resources/ directory of a provisioned IM instance. Use it to read lookup tables, Velocity templates, JSON configuration, or any other reference file that routes need at runtime.
URI pattern: pfx-resources:load[?options]
Methods
|
Method |
Description |
|---|---|
|
|
Load a file from |
Parameters
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
String |
— |
Required. File name (or relative path) inside |
|
|
boolean |
|
Store the loaded content in a header instead of replacing the body |
Examples
Load a CSV lookup table
<routes xmlns="http://camel.apache.org/schema/spring">
<route id="importWithLookup">
<from uri="timer://run?repeatCount=1"/>
<to uri="pfx-resources:load?name=country-codes.csv&setToHeader=true"/>
<setHeader name="countryCodes">
<simple>${body}</simple>
</setHeader>
<to uri="pfx-api:fetch?objectType=C&filter=allCustomers"/>
<to uri="pfx-api:integrate?objectType=C&mapper=customerMapper"/>
</route>
</routes>
Load a Velocity template
<to uri="pfx-resources:load?name=templates/notification.vm"/>
<!-- body now contains the template string -->
Load JSON config file
<to uri="pfx-resources:load?name=config/field-mapping.json"/>
<to uri="pfx-json:unmarshal"/>
<!-- body is now a Map from the JSON config -->
File Placement
Files must be placed in the resources/ directory of the provisioned IM repository:
resources/
├── country-codes.csv
├── config/
│ └── field-mapping.json
└── templates/
└── notification.vm
The name parameter is relative to the resources/ root.
Common Pitfalls
-
Files in
resources/are not auto-loaded at startup — they are fetched on demand by the route. -
resources/is the only directory in the provisioned layout that is not auto-loaded by the Camel context. -
Use
setToHeader=truewhen you need the resource available alongside the current body (e.g., a lookup table used in mapper Groovy expressions). -
File names are case-sensitive on Linux deployments (AWS/GCP). Use consistent casing.