Hi zappee,

I think If you want manage some header and class syntactically (compile
time)
you should use Processor feature [1]

from("....").process(new Processor() {
    public void process(Exchange exchange) throws Exception {
        Person payload = exchange.getIn().getBody(Person.class);
        // do something with the payload and/or exchange here
       exchange.getIn().setHeader("to", payload.getEmail());
   }
}).to("....");

[1] http://camel.apache.org/processor.html


Best Regards, Bien à vous,  どうぞお元気で,
____________________________________________________
Greg AUTRIC
- JBoss Middleware Consultant -


On Sun, Feb 7, 2016 at 3:32 PM, zappee <arnold.somo...@gmail.com> wrote:
>
> Hi,
>
> I want to send emails with an smtp endpoint. Source endpoint: message
queue.
> Source message type: Person.class bean.
> I need to read the Person.email parameter somehow at the beginning of my
> route and save the value of the email bean parameter for the further
> processing. I want to use this value as a "to" parameter of my smtp
> endpoint.
>
> I suppose that I can read the bean (which is on the body at the beginning
of
> my route) via Simple like this: simple("${header.email}"). But if I rename
> the email member variable with my IDE (and getter/setter methods are
renamed
> as well) then my code still correct syntactically because "email" is
> referenced as a string and my IDE wont rename this part of my code.
>
> Can I do something like this: setHeader("to",
> body().convertTo(Person.class).getEmail()) ?
>
>
> String emailEndpoint =
> "smtp://smtp.gmail.com:587?username=..&password=...&*to=%s*";
>
> from(queueEndpointUrl)
>    .log(LoggingLevel.DEBUG, LOGGER, "email sending...")
>    .*setHeader("to", simple("${header.email}"))*
>    .to("velocity:file:/....)
>    .convertBodyTo(String.class)
>    .log("Email is ready for send")
>    .to( String.format(emailEndpoint, header("to"))
>    .log("Email successfully sent");
>
>
>
>
>
>
> --
> View this message in context:
http://camel.465427.n5.nabble.com/type-save-body-unboxing-tp5777342.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to