On 12/11/2007, ruben.martin <[EMAIL PROTECTED]> wrote:
>
> Now I need to decide the email recipient when i actually send the request and
> not in configuration time ( with the '[EMAIL PROTECTED]'). Is
> there any way of specifying this address with a header in the same way that
> the subject?
>
> from("direct:a")
> .to("smtp://[EMAIL PROTECTED]:[EMAIL PROTECTED]")
>
>
> Exchange response = template.request("direct:a", new Processor() {
> public void process(Exchange exchange) throws Exception {
> Message in = exchange.getIn();
> in.setBody("------");
> in.setHeader("subject", "My Subject");
>
> }
> });
So at runtime you can decide what endpoint URI to send to dynamically.
e.g. this could be using a content based router...
http://activemq.apache.org/camel/content-based-router.html
or using a Dynamic Recipient List
http://activemq.apache.org/camel/recipient-list.html
where you use some expression to decide the endpoint URI using an expression.
Finally you could just use a Bean which is injected with a
ProducerTemplate to decide using Java code...
public class MyBean implements Processor
@EndpointInject(uri="someDefaultUri")
ProducerTemplate template;
public void process(Exchange exchange) {
String uri = ...; // use some Java code to figure out the endpoint
template.send(uri, exchange);
}
}
then in the route do
from("something").beanRef("myBean");
for more info on using beans see
http://activemq.apache.org/camel/bean-integration.html
--
James
-------
http://macstrac.blogspot.com/
Open Source SOA
http://open.iona.com