如何将交换报头设置为路由的结果



我有一个驼峰路由,其中有一个步骤调用子路由将正文的文本部分转换为PDF。不幸的是,camel-pdf不保留头。有没有一种方法可以让我在不失去我当前的交换的情况下获得子路由的价值?

<

子路线/strong>

from("seda:generate-pdf")
// Back up the original in a header
.setHeader("original", body())
// Create the PDF
.to("pdf:create?textProcessingFactory=autoFormatting")
// UHOH! All my headers are gone :(
// Set the PDF as the header for the doc server
.setHeader("pdf", body())
// Move the indicator back to the body
.setBody(header("original")) // <-- this no longer exists
<

主要路线/strong>

// Snip
// Unmarshal into Java
.unmarshal().json(JsonLibrary.Gson, MyReportContainingText.class)
// Call sub-route to generate the PDF
.inOut("seda:generate-pdf")
// UHOH! All my headers are gone :(
// Snip

不要在header中保存那些当你从一个路由传递到另一个路由时可能被删除的东西,而要将它们保存为exchange属性。例如:

.setProperty("pdf", body())
.setProperty("pdf", simple("${body}")

只要交换存在,交换属性就存在。

最新更新