camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Sending an email with Camel
Date Mon, 17 Sep 2007 10:17:37 GMT
On 9/17/07, bgoetzmann <bgoetzmann@sophia.symag.com> wrote:
>
> Thank you James.
>
> Using the Java code you indicated:
>
> MailComponent component = new MailComponent();
> component.getConfiguration().setHost("myMailServerHost");
> ...
>
> Does the instance must be put in a Camel context? Like this:
> camelContext.put("mail", component);

Yes, or...

> Sorry, I don't see the relation with JNDI, and the URI I can use like in my
> sample code.
> Must I use something like ... .to(smtp://...) or ... .to(mail: ...)?

So when you use a URI in camel, it tries to find the endpoint in your
registry (which is usually the ApplicationContext if you're a spring
user or JNDI if not). Then if it can't find it, it takes the scheme
(mail, or smtp, pop3 or whatever) and tries to find a Component in the
register for that -if it does it then asks the Component to make the
endpoint.

You can avoid the use of a Registry if you prefer and just put your
components/endpoints into the CamelContext directly.


> > so if you are using spring you could do something like
> >
> > <bean id="mail" class="org.apache.camel.component.mail.MailComponent">
> >   <property name="configuration">
> >    <bean class="org.apache.camel.component.mail.MailConfiguration">
> >      <property name="host" value="myMailServerHost">
> > ...

So in this example the "mail" entry in the ApplicationContext will
point to the configured mail compnent.


> > or if you are using Java code and not using spring you could add a
> > configured MailComponent into JNDI
> >
> >
> > MailComponent component = new MailComponent();
> > component.getConfiguration().setHost("myMailServerHost");
> > context.put("mail", component);

Here we're adding the component into the initial JNDI context so that
the CamelContext can resolve "mail" endpoints.

The use of the registry is optional really; its really just there to
let folks use whatever they are already using (like JNDI in some app
server or Spring etc) to configure things.

-- 
James
-------
http://macstrac.blogspot.com/

Mime
View raw message