145.10. Samples
例如,您可以使用:
from("activemq:My.Queue").
to("velocity:com/acme/MyResponse.vm");
要使用 Velocity 模板,对 InOut 消息交换的消息做出响应(其中有一个 JMSReplyTo 标头)。
如果要使用 InOnly 并使用信息并将其发送到另一个目的地,您可以使用以下路由:
from("activemq:My.Queue").
to("velocity:com/acme/MyResponse.vm").
to("activemq:Another.Queue");
例如,要使用内容缓存(例如在生产环境中使用),其中 .vm 模板永不改变:
from("activemq:My.Queue").
to("velocity:com/acme/MyResponse.vm?contentCache=true").
to("activemq:Another.Queue");
和基于文件的资源:
from("activemq:My.Queue").
to("velocity:file://myfolder/MyResponse.vm?contentCache=true").
to("activemq:Another.Queue");
可以指定组件应该通过标头动态使用的模板,例如:
from("direct:in").
setHeader("CamelVelocityResourceUri").constant("path/to/my/template.vm").
to("velocity:dummy?allowTemplateFromHeader=true"");
可以直接将模板指定为标头,组件应该通过标头动态使用,例如:
from("direct:in").
setHeader("CamelVelocityTemplate").constant("Hi this is a velocity template that can do templating ${body}").
to("velocity:dummy?allowTemplateFromHeader=true"");