Hi, 

We have been using Camel ( version 2.10) to monitor/route and process
attachments to emails coming  in to one of our mailboxes.  At the end of the
processing some emails are copied to an Inbox folder using the
'.setHeader("copyTo")' method.
This has been working quite well. Now the users have asked for a new
requirement, where  some emails depending on the  type of email attachment
has to be copied to two Inbox folders. I tried to do this using multicast
and a custom onPrepare method on my processor to do a deep copy of the
message. But this always copies the email to only one of the folders. 
following is the route description and custom processor 

        
from("direct:incomingValidateAttachments").routeId("direct:incomingValidateAttachments")
                        //check the attachment to see if they are valid
                    .log(LoggingLevel.DEBUG,
logger,"direct:incomingValidateAttachments" + logMessage)
                    .doTry()
                    .to("direct:incomingSplitAttachments")
                    .doCatch(Throwable.class)
                                        //send the emails with invalid 
attachment to Inbox/errors folder
                    .log(LoggingLevel.DEBUG, logger, "Error catched")
                    .setHeader("copyTo").constant("Inbox/errors")
                    .end()
                                        //copy valid emails two Inbox folders 
communications and datafeeds
                    .multicast().onPrepare(new MessageClonePrepare())//using
custom processor for copying  the mail message
                    .to("direct:coptToComms")
                    .to("direct:coptToDataFeeds");
                                        
                //copy email to communications folder
        from("direct:coptToComms").routeId("direct:coptToComms")
                .log(LoggingLevel.DEBUG, logger, "direct:coptToComms" +
logMessage)
                .setHeader("copyTo").constant("Inbox/Comms");
             

            // Send the email to the data feed folder
         from("direct:coptToDataFeeds").routeId("direct:coptToDataFeeds")
                    .log(LoggingLevel.DEBUG, logger,
"direct:coptToDataFeeds" + logMessage)
                    .setHeader("copyTo").constant("Inbox/DataFeeds");
                                        
//Class to copy the email message during Multicast 
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.NoSuchHeaderException;
import org.apache.camel.Processor;
import org.apache.camel.component.mail.MailMessage;

public class MessageClonePrepare implements Processor {
    public void process(Exchange exchange) throws NoSuchHeaderException {
        
        Message in = exchange.getIn();
        Message newMessage = new MailMessage();
        newMessage.setBody(in.getBody());
        newMessage.setAttachments(in.getAttachments());
        newMessage.setHeaders(in.getHeaders());
        exchange.setIn(newMessage);
        
    }
}

 
Please could you help me to find what I am doing wrong?
Is using multicast the correct way to copy an email in two Inbox folders? 




--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Multicast-copying-email-to-two-Inbox-folders-tp5772679.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to