3
我正在用駱駝編寫一些路由,並且我想使用處理器進行一些轉換。我有一個屬性文件,它工作正常。如何在駱駝處理器中使用屬性佔位符
from(URI_LOG)
.routeId("{{PREFIX_LOG}}.prepareForMQ")
.log("Mail to: {{MAIL}}") //The value is read from a property file
.process(new ProcessorPrepareMail())
.log("${body}");
現在...我想讀取處理器中{{MAIL}}的值,但我不知道如何。
我想這些東西:
public class ProcessorPrepareMail implements Processor
{
@Override
public void process(Exchange exchange) throws Exception
{
//Plan A: Does not work.... I get an empty String
String mail = exchange.getProperty("MAIL", String.class);
//Plan B: Does not work.... I get the String "{{MAIL}}"
Language simple = exchange.getContext().resolveLanguage("simple");
Expression expresion = simple.createExpression("{{MAIL}}");
String valor = expresion.evaluate(exchange, String.class);
//Plan C: Does not work. It activates the default error handler
Language simple = exchange.getContext().resolveLanguage("simple");
Expression expresion = simple.createExpression("${MAIL}");
String valor = expresion.evaluate(exchange, String.class);
}
}
你能幫助我嗎?
感謝
好極了!謝謝! – Desenfoque