You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Dan Checkoway <dc...@gmail.com> on 2011/01/16 06:29:11 UTC

Queue email to JMS then route to mail component

I'm pretty sure this is NOT possible, but I want to confirm...

I have various apps running on a handful of servers, and each of the apps
needs to send email at one point or another.  I don't want the apps talking
SMTP directly.  What I'd like is...when the apps need to send email, they
just queue the outbound email message to JMS (ActiveMQ).  Then in one spot
where I *can* talk SMTP, I'd like to set up a route like:

from("activemq:queue:email.outbound")
.to("smtps:user@mailserver:port?...");

My understanding is that this will work ok as long as I'm sending plain
non-multipart email (i.e. no attachments).  Just body and headers, and
that's it.  Pretty sure that will work.  But as far as I can tell, if I need
to add attachments, the JMS component will NOT propagate the attachments.  I
can understand why...you can't serialize a DataHandler (right?), and it's
theoretically undesirable to have to *copy* full content from all attached
DataHandlers.  The message could get unwieldy.  Anyway, I looked at the
source for the JMS component, and it appears that JmsBinding doesn't even
look at attachments.  Understandable.

Does all of this sound correct?  Or am I missing some way to use JMS as a
go-between for sending multipart messages with attachments?

Thanks,
Dan

Re: Queue email to JMS then route to mail component

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Jan 16, 2011 at 6:29 AM, Dan Checkoway <dc...@gmail.com> wrote:
> I'm pretty sure this is NOT possible, but I want to confirm...
>
> I have various apps running on a handful of servers, and each of the apps
> needs to send email at one point or another.  I don't want the apps talking
> SMTP directly.  What I'd like is...when the apps need to send email, they
> just queue the outbound email message to JMS (ActiveMQ).  Then in one spot
> where I *can* talk SMTP, I'd like to set up a route like:
>
> from("activemq:queue:email.outbound")
> .to("smtps:user@mailserver:port?...");
>
> My understanding is that this will work ok as long as I'm sending plain
> non-multipart email (i.e. no attachments).  Just body and headers, and
> that's it.  Pretty sure that will work.  But as far as I can tell, if I need
> to add attachments, the JMS component will NOT propagate the attachments.  I
> can understand why...you can't serialize a DataHandler (right?), and it's
> theoretically undesirable to have to *copy* full content from all attached
> DataHandlers.  The message could get unwieldy.  Anyway, I looked at the
> source for the JMS component, and it appears that JmsBinding doesn't even
> look at attachments.  Understandable.
>
> Does all of this sound correct?  Or am I missing some way to use JMS as a
> go-between for sending multipart messages with attachments?
>

Attachments is not propagated over JMS. There is no good API support for that.
You can use the claim check EIP pattern and store the attachments in a
file system
and then re-load them on the consumer side.

Alternative you can move the attachments inside the message body in a
custom java object.
And then "de-serailize" that on the other side.

For example using a custom data format.


An alternative is we could maybe improve the transferExchange option
in Camel (supported by JMS) to also serialize attachments if that's
possible.
You can read about the option here: http://camel.apache.org/jms


> Thanks,
> Dan
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/