Samples - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

For example you could use something like

from("activemq:My.Queue")
   .to("velocity:com/acme/MyResponse.vm");

To use a Velocity template to formulate a response to a message for InOut message exchanges (where there is a JMSReplyTo header).

If you want to use InOnly and consume the message and send it to another destination, you could use the following route:

from("activemq:My.Queue")
   .to("velocity:com/acme/MyResponse.vm")
   .to("activemq:Another.Queue");

And to use the content cache, for example, for use in production, where the .vm template never changes:

from("activemq:My.Queue")
   .to("velocity:com/acme/MyResponse.vm?contentCache=true")
   .to("activemq:Another.Queue");

And a file based resource:

from("activemq:My.Queue")
   .to("velocity:file://myfolder/MyResponse.vm?contentCache=true")
   .to("activemq:Another.Queue");

In it is possible to specify what template the component should use dynamically via a header, so for example:

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

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

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