Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Velocity template resource is, by default, hot reloadable for both file and classpath resources (expanded jar). If you set contentCache=true, Camel will only load the resource once, and thus hot reloading is not possible. This scenario can be used in production, when the resource never changes.

Dynamic templates

Available as of Camel 2.1
Camel provides two headers by which you can define a different resource location for a template or the template content itself. If any of these headers is set then Camel uses this over the endpoint configured resource. This allows you to provide a dynamic template at runtime.

Header

Type

Description

CamelVelocityResourceUri

String

Camel 2.1: A URI for the template resource to use instead of the endpoint configured.

CamelVelocityTemplate

String

CAmel 2.1: The template to use instead of the endpoint configured.

Samples

For example you could use something like

...

Code Block
from("direct:in").
  setHeader("CamelVelocityResourceUri").constant("path/to/my/template.vm").
  to("velocity:dummy");

In Camel 2.1 it's possible to specify a template directly as a header the component should use dynamically via a header, so for example:

Code Block

from("direct:in").
  setHeader("CamelVelocityTemplate").constant("Hi this is a velocity template that can do templating ${body}").
  to("velocity:dummy");

...