[CONF] Apache Camel > Velocity

2014-07-08 Thread willem jiang (Confluence)














  


willem jiang edited the page:
 


Velocity   




 Comment: CAMEL-7532 


...
Maven users will need to add the following dependency to their pom.xml for this component:



 Code Block









xml


 




 


org.apache.camel
camel-velocity
x.x.x


 



URI format



 Code Block




 

velocity:templateName[?options]
 



...
For example, to set the header value of fruit in the Velocity template .tm:



 Code Block




 

$in.setHeader('fruit', 'Apple')
 



...


   

[CONF] Apache Camel > Velocity

2012-09-07 Thread confluence







Velocity
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (5)
 




...
|| Option || Default || Description || | {{loaderCache}} | {{true}} | Velocity based file loader cache. | 
| {{contentCache}} |  | New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's {{false}} in Camel 1.x. By default, it's {{true}} in Camel 2.x.  \\ Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's {{clearContentCache}} operation. | 
| {{contentCache}} | {{true}} | Cache for the resource content when it is loaded. \\ Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's {{clearContentCache}} operation. | 
| {{encoding}} | {{null}} | New option in Camel 1.6: Character encoding of the resource content. | 
| {{propertiesFile}} | {{null}} | New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. |  {div} 
...
{div:class=confluenceTableSmall} || Header || Description || 
| {{CamelVelocityResourceUri}} | Camel 2.0: The *templateName* as a {{String}} object. | 
{div}  
In Camel 1.4 headers Headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message. 
 For example, to set the header value of {{fruit}} in the Velocity template {{.tm}}: 
...


Full Content

Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

Maven users will need to add the following dependency to their pom.xml for this component:



org.apache.camel
camel-velocity
x.x.x





URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 true 
 Cache for the resource content when it is loaded.  Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's clearContentCache operation. 


 encoding 
 null 
 Character encoding of the resource content. 


 propertiesFile 
 null 
 New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. 





Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support):



 Header 
 Description 


 CamelVelocityResourceUri 
 The templateName as a String object. 





Headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:



 key 
 value 


 exchange 
 The Exchange itself. 


 exchange.properties 
 The Exchange properties. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 





Hot reloading
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 confi

[CONF] Apache Camel > Velocity

2012-04-29 Thread confluence







Velocity
Page edited by Claus Ibsen


 Changes (1)
 




...
{div:class=confluenceTableSmall} || Header || Description || 
| {{org.apache.camel.velocity.resource}} | Camel 1.x: The resource as an {{org.springframework.core.io.Resource}} object. | | {{org.apache.camel.velocity.resourceUri}} | Camel 1.x: The *templateName* as a {{String}} object. | | {{CamelVelocityResource}} | Camel 2.0: The resource as an {{org.springframework.core.io.Resource}} object. | 
| {{CamelVelocityResourceUri}} | Camel 2.0: The *templateName* as a {{String}} object. | {div} 
...


Full Content

Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

Maven users will need to add the following dependency to their pom.xml for this component:



org.apache.camel
camel-velocity
x.x.x





URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x.   Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's clearContentCache operation. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 


 propertiesFile 
 null 
 New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. 





Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support):



 Header 
 Description 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 





In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:



 key 
 value 


 exchange 
 The Exchange itself. 


 exchange.properties 
 The Exchange properties. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 





Hot reloading
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



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, e.g. 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

[CONF] Apache Camel > Velocity

2011-12-08 Thread confluence







Velocity
Page edited by Rich Newcomb


 Changes (1)
 




...
|| Option || Default || Description || | {{loaderCache}} | {{true}} | Velocity based file loader cache. | 
| {{contentCache}} |  | New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's {{false}} in Camel 1.x. By default, it's {{true}} in Camel 2.x. Note : as of *Camel 2.9* cached resource content can be cleared via JMX using the endpoint's {{clearContentCache}} operation. | 
| {{encoding}} | {{null}} | New option in Camel 1.6: Character encoding of the resource content. | | {{propertiesFile}} | {{null}} | New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. |  
...


Full Content

Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

Maven users will need to add the following dependency to their pom.xml for this component:



org.apache.camel
camel-velocity
x.x.x





URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x.   Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's clearContentCache operation. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 


 propertiesFile 
 null 
 New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. 





Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support):



 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 





In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:



 key 
 value 


 exchange 
 The Exchange itself. 


 exchange.properties 
 The Exchange properties. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 





Hot reloading
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



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 

[CONF] Apache Camel > Velocity

2011-12-08 Thread confluence







Velocity
Page edited by Rich Newcomb


 Changes (1)
 




...
|| Option || Default || Description || | {{loaderCache}} | {{true}} | Velocity based file loader cache. | 
| {{contentCache}} |  | New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's {{false}} in Camel 1.x. By default, it's {{true}} in Camel 2.x. Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's {{clearContentCache}} operation. | 
| {{encoding}} | {{null}} | New option in Camel 1.6: Character encoding of the resource content. | | {{propertiesFile}} | {{null}} | New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. |  
...


Full Content

Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

Maven users will need to add the following dependency to their pom.xml for this component:



org.apache.camel
camel-velocity
x.x.x





URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x.   Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's clearContentCache operation. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 


 propertiesFile 
 null 
 New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. 





Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support):



 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 





In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:



 key 
 value 


 exchange 
 The Exchange itself. 


 exchange.properties 
 The Exchange properties. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 





Hot reloading
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



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 In

[CONF] Apache Camel > Velocity

2011-12-08 Thread confluence







Velocity
Page edited by Rich Newcomb


 Changes (1)
 




...
|| Option || Default || Description || | {{loaderCache}} | {{true}} | Velocity based file loader cache. | 
| {{contentCache}} |  | New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's {{false}} in Camel 1.x. By default, it's {{true}} in Camel 2.x. Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's {{clearContentCache}} operation. | 
| {{encoding}} | {{null}} | New option in Camel 1.6: Character encoding of the resource content. | | {{propertiesFile}} | {{null}} | New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. |  
...


Full Content

Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

Maven users will need to add the following dependency to their pom.xml for this component:



org.apache.camel
camel-velocity
x.x.x





URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x.   Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's clearContentCache operation. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 


 propertiesFile 
 null 
 New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. 





Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support):



 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 





In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:



 key 
 value 


 exchange 
 The Exchange itself. 


 exchange.properties 
 The Exchange properties. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 





Hot reloading
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



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 In

[CONF] Apache Camel > Velocity

2011-10-27 Thread confluence







Velocity
Page edited by Christian Mueller


 Changes (1)
 




...
|| key || value || | {{exchange}} | The {{Exchange}} itself. | 
| {{exchange.properties}} | The {{Exchange}} properties. | 
| {{headers}} | The headers of the In message. | | {{camelContext}} | The Camel Context intance. | 
...


Full Content

Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

Maven users will need to add the following dependency to their pom.xml for this component:



org.apache.camel
camel-velocity
x.x.x





URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 


 propertiesFile 
 null 
 New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. 





Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support):



 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 





In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:



 key 
 value 


 exchange 
 The Exchange itself. 


 exchange.properties 
 The Exchange properties. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 





Hot reloading
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



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, e.g. 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").
 

[CONF] Apache Camel > Velocity

2010-05-21 Thread confluence







Velocity
Page edited by Claus Ibsen


 Changes (6)
 



...
 h3. Options 
  {div:class=confluenceTableSmall} 
|| Option || Default || Description || | {{loaderCache}} | {{true}} | Velocity based file loader cache. | 
...
| {{encoding}} | {{null}} | New option in Camel 1.6: Character encoding of the resource content. | | {{propertiesFile}} | {{null}} | New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. |  
{div} 
 h3. Message Headers  The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support): 
{div:class=confluenceTableSmall} 
|| Header || Description || | {{org.apache.camel.velocity.resource}} | Camel 1.x: The resource as an {{org.springframework.core.io.Resource}} object. | 
...
| {{CamelVelocityResource}} | Camel 2.0: The resource as an {{org.springframework.core.io.Resource}} object. | | {{CamelVelocityResourceUri}} | Camel 2.0: The *templateName* as a {{String}} object. | 
{div} 
 In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message. 
...
*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. 
  {div:class=confluenceTableSmall} 
|| 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. | 
{div} 
 h3. Samples 
...

Full Content

Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 


 propertiesFile 
 null 
 New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. 





Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support):



 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 





In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:



 key 
 value 


 exchange 
 The Exchange itself. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 





Hot reloading
The Velocity template resource is, by default, hot reloadable for both file and classpath resources (expanded j

[CONF] Apache Camel > Velocity

2010-02-03 Thread confluence







 Velocity
 Page edited by James Strachan

 updated by accident 
  
 updated by accident 
 
  
 
 Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 


 propertiesFile 
 null 
 New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. 



Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support):


 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 



In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 



Hot reloading
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



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, e.g. 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 Camel 2.1 it's 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 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:



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



The Email Sample
In this sample we want 

[CONF] Apache Camel > Velocity

2010-02-03 Thread confluence







 Velocity
 Page edited by James Strachan

 
  
 
 Scalate

The scalate: component allows you to process a message using Scalate template, which supports either SSP or Scaml format templates. This can be ideal when using Templating to generate responses for requests.

URI format



scalate:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.ssp).

You can append query options to the URI in the following format, ?option=value&option=value&...

Message Headers

The scalate component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 scalate component will not set these headers which will cause some side effect on the dynamic template support):


 Header 
 Description 


 CamelScalateResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelScalateResourceUri 
 Camel 2.0: The templateName as a String object. 



Headers set during the Scalate evaluation are returned to the message and added as headers. Then its kinda possible to return values from Scalate to the Message.

For example, to set the header value of fruit in the Scalate template .tm:



$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Scalate Context
Camel will provide exchange information in the Scalate context (just a Map). The Exchange is transfered as:



 key 
 value 


 exchange 
 The Exchange itself. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 



Hot reloading
The Scalate template resource is, by default, hot reloadable for both file and classpath resources (expanded jar). 

Dynamic templates

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 


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


 CamelScalateTemplate 
 String 
 Camel 2.1: The template to use instead of the endpoint configured. 



Samples

For example you could use something like



from("activemq:My.Queue").
  to("scalate:com/acme/MyResponse.ssp");



To use a Scalate 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("scalate:com/acme/MyResponse.haml").
  to("activemq:Another.Queue");



It's possible to specify what template the component should use dynamically via a header, so for example:



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



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



from("direct:in").
  setHeader("CamelScalateTemplate").constant("<%@ attribute body: Object %>\nHi this is a scalate template that can do templating ${body}").
  to("scalate:dummy");



The Email Sample
In this sample we want to use Scalate templating for an order confirmation email. The email template is laid out in Scalate as:


<%@ attribute in: org.apache.camel.scala.RichMessage %>
Dear ${in("lastName"}, ${in("firstName)}

Thanks for the order of ${in("item")}.

Regards Camel Riders Bookstore
${in.body}



See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started


 
 
   
Change Notification Preferences
   

   View Online
   |
   View Change
  |
   Add Comment









[CONF] Apache Camel > Velocity

2009-10-26 Thread confluence







 Velocity
 Page edited by willem jiang

 CAMEL-2091
  
 CAMEL-2091
 
  
 
 Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 


 propertiesFile 
 null 
 New option in Camel 2.1: The URI of the properties file which is used for VelocityEngine initialization. 



Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1 velocity component will not set these headers which will cause some side effect on the dynamic template support):


 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 



In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 



Hot reloading
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



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, e.g. 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 Camel 2.1 it's 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 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:



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



The Email Sample
In this sample we want to use Velocity templa

[CONF] Apache Camel > Velocity

2009-10-22 Thread confluence







 Velocity
 Page edited by willem jiang

 
  
 
 Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 



Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself and from Camel 2.1, velocity component will not set these headers which will cause some side effect on the dynamic template support):


 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 



In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 



Hot reloading
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



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, e.g. 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 Camel 2.1 it's 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 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:



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



The Email Sample
In this sample we want to use Velocity templating for an order confirmation email. The email template is laid out in Velocity as:


Dear ${headers.lastName}, ${headers.firstName}

Thanks for the order of ${headers.item}.

[CONF] Apache Camel > Velocity

2009-09-18 Thread confluence







 Velocity
 Page edited by Claus Ibsen

 
  
 
 Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 



Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself):


 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 



In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 



Hot reloading
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



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, e.g. 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 Camel 2.1 it's 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 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:



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



The Email Sample
In this sample we want to use Velocity templating for an order confirmation email. The email template is laid out in Velocity as:


Dear ${headers.lastName}, ${headers.firstName}

Thanks for the order of ${headers.item}.

Regards Camel Riders Bookstore
${body}



And the java code:


private Exchange createLetter() {
Exchange exchange = context.ge

[CONF] Apache Camel > Velocity

2009-09-15 Thread confluence







 Velocity
 Page edited by Stan Lewis

 
  
 
 Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 



Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself):


 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 



In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 



Hot reloading
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.

Samples

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, e.g. 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 Camel 2.1 it's 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");



The Email Sample
In this sample we want to use Velocity templating for an order confirmation email. The email template is laid out in Velocity as:


Dear ${headers.lastName}, ${headers.firstName}

Thanks for the order of ${headers.item}.

Regards Camel Riders Bookstore
${body}



And the java code:


private Exchange createLetter() {
Exchange exchange = context.getEndpoint("direct:a").createExchange();
Message msg = exchange.getIn();
msg.setHeader("firstName", "Claus");
msg.setHeader("lastName", "Ibsen");
msg.setHeader("item", "Camel in Action");
msg.setBody("PS: Next beer is on me, James");
return exchange;
}

@Test
public void testVelocityLetter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the order of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on me, James");

template.send("direct:a", createLetter());

mock.assertIsSatisfied();
}

protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:a").to("velocity:org/apache/camel/component/v

[CONF] Apache Camel > Velocity

2009-09-14 Thread confluence







 Velocity
 Page edited by Stan Lewis

 
  
 
 Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format



velocity:templateName[?options]



Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 



Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself):


 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 



In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:


$in.setHeader('fruit', 'Apple')



The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 



Hot reloading
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.

Samples

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, e.g. 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 Camel 2.1 it's 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");



The Email Sample
In this sample we want to use Velocity templating for an order confirmation email. The email template is laid out in Velocity as:


Dear ${headers.lastName}, ${headers.firstName}

Thanks for the order of ${headers.item}.

Regards Camel Riders Bookstore
${body}



And the java code:


private Exchange createLetter() {
Exchange exchange = context.getEndpoint("direct:a").createExchange();
Message msg = exchange.getIn();
msg.setHeader("firstName", "Claus");
msg.setHeader("lastName", "Ibsen");
msg.setHeader("item", "Camel in Action");
msg.setBody("PS: Next beer is on me, James");
return exchange;
}

@Test
public void testVelocityLetter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the order of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on me, James");

template.send("direct:a", createLetter());

mock.assertIsSatisfied();
}

protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:a").to("velocity:org/apache/camel/component/v

[CONF] Apache Camel > Velocity

2009-07-22 Thread confluence







 Velocity
 Page edited by Jonathan Anstey

 
  
 
 Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format















velocity:templateName[?options]




Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

You can append query options to the URI in the following format, ?option=value&option=value&...

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache. 


 contentCache 
 
 New option in Camel 1.4: Cache for the resource content when it is loaded. By default, it's false in Camel 1.x. By default, it's true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6: Character encoding of the resource content. 



Message Headers

The velocity component sets a couple headers on the message (you can't set these yourself):


 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as a String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityResourceUri 
 Camel 2.0: The templateName as a String object. 



In Camel 1.4 headers set during the Velocity evaluation are returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

For example, to set the header value of fruit in the Velocity template .tm:

$in.setHeader('fruit', 'Apple')




The fruit header is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself. 


 headers 
 The headers of the In message. 


 camelContext 
 The Camel Context intance. 


 request 
 The In message. 


 in 
 The In message. 


 body 
 The In message body. 


 out 
 The Out message (only for InOut message exchange pattern). 


 response 
 The Out message (only for InOut message exchange pattern). 



Hot reloading
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.

Samples

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, e.g. 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");




The Email Sample
In this sample we want to use Velocity templating for an order confirmation email. The email template is laid out in Velocity as:

Dear ${headers.lastName}, ${headers.firstName}

Thanks for the order of ${headers.item}.

Regards Camel Riders Bookstore
${body}




And the java code:















private Exchange createLetter() {
Exchange exchange = context.getEndpoint("direct:a").createExchange();
Message msg = exchange.getIn();
msg.setHeader("firstName", "Claus");
msg.setHeader("lastName", "Ibsen");
msg.setHeader("item", "Camel in Action");
msg.setBody("PS: Next beer is on me, James");
return exchange;
}

@Test
public void testVelocityLetter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the order of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on me, James");

template.send("direct:a", createLetter());

mock.assertIsSatisfied();
}

protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:a").to("velocity:org/apache/camel/component/velocity/letter.vm").to("mock:result");
}
};
}




See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started


 
 
   
Change Notification Preferences
   

   Vi

[CONF] Apache Camel: Velocity (page edited)

2009-02-27 Thread confluence










Page Edited :
CAMEL :
Velocity



 
Velocity
has been edited by Claus Ibsen
(Feb 27, 2009).
 

 
 (View changes)
 

Content:
Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format


velocity:templateName


Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache 


 contentCache 
 
 New option in Camel 1.4. Cache for the resource content when its loaded. Is default false in Camel 1.x. Is default true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6. Character encoding of the resource content. 



Message Headers



 Header 
 Description 


 org.apache.camel.velocity.resource 
 Camel 1.x: The resource as an org.springframework.core.io.Resource object. 


 org.apache.camel.velocity.resourceUri 
 Camel 1.x: The templateName as String object. 


 CamelVelocityResource 
 Camel 2.0: The resource as an org.springframework.core.io.Resource object. 


 CamelVelocityRsourceUri 
 Camel 2.0: The templateName as String object. 



In Camel 1.4 headers set during the velocity evaluation is returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

An example: Set the header value of fruit in the Velocity template .tm:

$in.setHeader('fruit', 'Apple')


The header 'fruit' is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself 


 headers 
 The headers of the in message 


 camelContext 
 The Camel Context 


 request 
 The in message 


 in 
 The in message 


 body 
 The in message body


 out 
 The out message (only for InOut message exchange pattern) 


 response 
 The out message (only for InOut message exchange pattern) 



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

Samples

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 for 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


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


And to use content cache, eg. for production usage 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");


The Email Sample
In this sample we want to use Velocity as templating for an order confirmation email. The email template is laid out in Velocity as:

Dear ${headers.lastName}, ${headers.firstName}

Thanks for the order of ${headers.item}.

Regards Camel Riders Bookstore
${body}


And the java code:


private Exchange createLetter() {
Exchange exchange = context.getEndpoint("direct:a").createExchange();
Message msg = exchange.getIn();
msg.setHeader("firstName", "Claus");
msg.setHeader("lastName", "Ibsen");
msg.setHeader("item", "Camel in Action");
msg.setBody("PS: Next beer is on me, James");
return exchange;
}

public void testVelocityLetter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the order of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on me, James");

template.send("direct:a", createLetter());

mock.assertIsSatisfied();
}

protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:a").to("velocity:org/apache/camel/component/velocity/letter.vm").to("mock:result");
}
};
}


See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started













Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences








[CONF] Apache Camel: Velocity (page edited)

2009-02-10 Thread confluence










Page Edited :
CAMEL :
Velocity



 
Velocity
has been edited by Claus Ibsen
(Feb 10, 2009).
 

 
 (View changes)
 

Content:
Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format


velocity:templateName


Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache 


 contentCache 

	


 New option in Camel 1.4. Cache for the resource content when its loaded. Is default false in Camel 1.x. Is default true in Camel 2.x. 


 encoding 
 null 
 New option in Camel 1.6. Character encoding of the resource content. 



Headers
Camel will store a reference to the resource in the message header in the key org.apache.camel.velocity.resource. The Resource is an org.springframework.core.io.Resource object.

In Camel 1.4 headers set during the velocity evaluation is returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

An example: Set the header value of fruit in the Velocity template .tm:

$in.setHeader('fruit', 'Apple')


The header 'fruit' is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself 


 headers 
 The headers of the in message 


 camelContext 
 The Camel Context 


 request 
 The in message 


 in 
 The in message 


 body 
 The in message body


 out 
 The out message (only for InOut message exchange pattern) 


 response 
 The out message (only for InOut message exchange pattern) 



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

Samples

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 for 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


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


And to use content cache, eg. for production usage 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");


The Email Sample
In this sample we want to use Velocity as templating for an order confirmation email. The email template is laid out in Velocity as:

Dear ${headers.lastName}, ${headers.firstName}

Thanks for the order of ${headers.item}.

Regards Camel Riders Bookstore
${body}


And the java code:


private Exchange createLetter() {
Exchange exchange = context.getEndpoint("direct:a").createExchange();
Message msg = exchange.getIn();
msg.setHeader("firstName", "Claus");
msg.setHeader("lastName", "Ibsen");
msg.setHeader("item", "Camel in Action");
msg.setBody("PS: Next beer is on me, James");
return exchange;
}

public void testVelocityLetter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the order of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on me, James");

template.send("direct:a", createLetter());

mock.assertIsSatisfied();
}

protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:a").to("velocity:org/apache/camel/component/velocity/letter.vm").to("mock:result");
}
};
}


See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started













Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences








[CONF] Apache Camel: Velocity (page edited)

2009-01-20 Thread confluence










Page Edited :
CAMEL :
Velocity



 
Velocity
has been edited by Jonathan Anstey
(Jan 20, 2009).
 

 
 (View changes)
 

Content:
Velocity

The velocity: component allows you to process a message using an Apache Velocity template. This can be ideal when using Templating to generate responses for requests.

URI format


velocity:templateName


Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.vm).

Options



 Option 
 Default 
 Description 


 loaderCache 
 true 
 Velocity based file loader cache 


 contentCache 
 false 
 New option in Camel 1.4. Cache for the resource content when its loaded. 


 encoding 
 null 
 New option in Camel 1.6. Character encoding of the resource content. 



Headers
Camel will store a reference to the resource in the message header in the key org.apache.camel.velocity.resource. The Resource is an org.springframework.core.io.Resource object.

In Camel 1.4 headers set during the velocity evaluation is returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.

An example: Set the header value of fruit in the Velocity template .tm:

$in.setHeader('fruit', 'Apple')


The header 'fruit' is now accessible from the message.out.headers.

Velocity Context
Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:


 key 
 value 


 exchange 
 The Exchange itself 


 headers 
 The headers of the in message 


 camelContext 
 The Camel Context 


 request 
 The in message 


 in 
 The in message 


 body 
 The in message body


 out 
 The out message (only for InOut message exchange pattern) 


 response 
 The out message (only for InOut message exchange pattern) 



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

Samples

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 for 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


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


And to use content cache, eg. for production usage 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");


The Email Sample
In this sample we want to use Velocity as templating for an order confirmation email. The email template is laid out in Velocity as:

Dear ${headers.lastName}, ${headers.firstName}

Thanks for the order of ${headers.item}.

Regards Camel Riders Bookstore
${body}


And the java code:

An error occurred: http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityLetterTest.java. The system administrator has been notified.

See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started













Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences