I'm writing some routes with camel, and I want to make some transformations using a Processor. I have a properties file and it is working ok.
from(URI_LOG)
.routeId("{{PREFIX_LOG}}.prepareForMQ")
.log("Mail to: {{MAIL}}") //The value is read from a property file
.process(new ProcessorPrepareMail())
.log("${body}");
Now... I want to read the value of {{MAIL}} inside the processor but I don't know how.
I tried these things:
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);
}
}
Can you help me?
Thanks