How to use resources

Resource usages

Resources for initial configuration

Resources are files that contain information that you want to add into the deployment. For example, you can have a resource that lists the currencies used in a payment-related application. In this case, the resource is manually injected.

The route definition would be:

<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
    <route>
        <!-- We use a 'direct' component for manual injection -->
        <from uri="direct:SetUpCurrencies" />
        <!-- Absorb them one by one -->
        <split>
            <simple>${body}</simple>
            <to uri="tnd-absorption:CreateCurrency" />
        </split>
    </route>
</routes>

Once the route is started, it's possible to inject the file and configure the currencies

Resources used to create a proper message

The best example is to create a configurable SQL request like described in the JDBC (Databases). It uses the StringTemplate component of Camel.

The string template uses the $ character as markup in order to inject variables. Thus if you need to use the $ sign you need to escape it and use \$ instead

Resources types

Text resources

When you use a text resource, it will be interpreted as a String using the given charset.

Binary resources

When you use a binary resource, it will be interpreted as a byte array even if its content is just text.

Related Links