Maven users will need to add the following dependency to their pom.xml for this component:
Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template.
You can append query options to the URI in the following format, ?option=value&option=value&...
Camel will store a reference to the resource in the message header with key, org.apache.camel.stringtemplate.resource. The Resource is an org.springframework.core.io.Resource object.
The string template resource is by default hot-reloadable for both file and classpath resources (expanded jar). If you set contentCache=true, Camel loads the resource only once and hot-reloading is not possible. This scenario can be used in production when the resource never changes.
Camel will provide exchange information as attributes (just a java.util.Map) to the string template. The Exchange is transfered as:
For example you could use a string template as follows in order to formulate a response to a message:
In this sample we want to use a string template to send an order confirmation email. The email template is laid out in StringTemplate as:
And the java code is as follows: