109.8. 샘플
예를 들어 다음과 같은 것을 사용할 수 있습니다.
from("activemq:My.Queue"). to("freemarker:com/acme/MyResponse.ftl");
from("activemq:My.Queue").
to("freemarker:com/acme/MyResponse.ftl");
FreeMarker 템플릿을 사용하여 InOut 메시지 교환( JMSReplyTo
헤더가 있는 경우) 메시지에 대한 응답을 작성합니다.
InOnly를 사용하고 메시지를 사용하여 다른 대상으로 보내려면 다음을 사용할 수 있습니다.
from("activemq:My.Queue"). to("freemarker:com/acme/MyResponse.ftl"). to("activemq:Another.Queue");
from("activemq:My.Queue").
to("freemarker:com/acme/MyResponse.ftl").
to("activemq:Another.Queue");
또한 .ftl
템플릿을 핫 다시 로드해야 하는 개발 용도의 경우와 같이 콘텐츠 캐시를 비활성화하려면 다음을 수행합니다.
from("activemq:My.Queue"). to("freemarker:com/acme/MyResponse.ftl?contentCache=false"). to("activemq:Another.Queue");
from("activemq:My.Queue").
to("freemarker:com/acme/MyResponse.ftl?contentCache=false").
to("activemq:Another.Queue");
및 파일 기반 리소스:
from("activemq:My.Queue"). to("freemarker:file://myfolder/MyResponse.ftl?contentCache=false"). to("activemq:Another.Queue");
from("activemq:My.Queue").
to("freemarker:file://myfolder/MyResponse.ftl?contentCache=false").
to("activemq:Another.Queue");
Camel 2.1 에서는 구성 요소가 헤더를 통해 동적으로 사용해야 하는 템플릿을 지정할 수 있습니다. 예를 들면 다음과 같습니다.
from("direct:in"). setHeader(FreemarkerConstants.FREEMARKER_RESOURCE_URI).constant("path/to/my/template.ftl"). to("freemarker:dummy?allowTemplateFromHeader=true");
from("direct:in").
setHeader(FreemarkerConstants.FREEMARKER_RESOURCE_URI).constant("path/to/my/template.ftl").
to("freemarker:dummy?allowTemplateFromHeader=true");
allowTemplateFromHeader
옵션을 활성화하면 보안 RAM이 있습니다. 예를 들어 헤더에 신뢰할 수 없거나 사용자가 파생된 콘텐츠가 포함된 경우 결국 최종 애플리케이션의 신뢰도와 무결성에 영향을 줄 수 있으므로 이 옵션을 신중하게 사용합니다.