pfx-resources Component

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

Load a file from resources/ into the body or a header


Parameters

Parameter

Type

Default

Description

name

String

Required. File name (or relative path) inside resources/

setToHeader

boolean

false

Store the loaded content in a header instead of replacing the body


Examples

Load a CSV lookup table

XML
<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&amp;setToHeader=true"/>
        <setHeader name="countryCodes">
            <simple>${body}</simple>
        </setHeader>
        <to uri="pfx-api:fetch?objectType=C&amp;filter=allCustomers"/>
        <to uri="pfx-api:integrate?objectType=C&amp;mapper=customerMapper"/>
    </route>
</routes>

Load a Velocity template

XML
<to uri="pfx-resources:load?name=templates/notification.vm"/>
<!-- body now contains the template string -->

Load JSON config file

XML
<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=true when 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.