You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/02/28 17:36:42 UTC

svn commit: r917197 - in /james/server/trunk/spoolmanager/src/main/java/org/apache/james: ./ transport/camel/

Author: norman
Date: Sun Feb 28 16:36:41 2010
New Revision: 917197

URL: http://svn.apache.org/viewvc?rev=917197&view=rev
Log:
Use JMS for spooling. First prototype (JAMES-976). Needs some more thoughts..

Added:
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/InMemoryMail.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateEquals.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateNotEquals.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherMatch.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/RoutingSlipHeaderProcessor.java
Removed:
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailMessage.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/SpoolComponent.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/SpoolConsumer.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/SpoolEndPoint.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/SpoolProducer.java
Modified:
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherSplitter.java

Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java?rev=917197&r1=917196&r2=917197&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java Sun Feb 28 16:36:41 2010
@@ -40,6 +40,8 @@
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.ParseException;
 
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.ProducerTemplate;
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.commons.configuration.CombinedConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
@@ -58,6 +60,7 @@
 import org.apache.james.services.MailServer;
 import org.apache.james.services.SpoolRepository;
 import org.apache.james.services.store.Store;
+import org.apache.james.transport.camel.InMemoryMail;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Mailet;
@@ -93,11 +96,7 @@
      */
     private Store store;
 
-    /**
-     * The spool used for processing mail handled by this server.
-     */
-    private SpoolRepository spool;
-
+  
     /**
      * The root URL used to get mailboxes from the repository
      */
@@ -154,6 +153,8 @@
 
     private DNSService dns;
 
+    private ProducerTemplate producerTemplate;
+
     @Resource(name="domainlist")
     public void setDomainList(DomainList domains) {
         this.domains = domains;
@@ -164,6 +165,11 @@
         this.dns = dns;
     }
     
+    @Resource(name="producerTemplate")
+    public void setProducerTemplate(ProducerTemplate producerTemplate) {
+        this.producerTemplate = producerTemplate;
+    }
+    
     public final void setLog(Log logger) {
         this.logger = logger;
     }
@@ -265,15 +271,6 @@
             }
         }
 
-        try {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Using SpoolRepository: " + spool.toString());
-            }
-        } catch (Exception e) {
-            if (logger.isWarnEnabled()) {
-                logger.warn("Can't get spoolRepository: " + e);
-            }
-        }
 
         /*
         try {
@@ -325,15 +322,6 @@
         this.store = store;
     }
 
-    /**
-     * Set the SpoolRepository to use
-     * 
-     * @param spool the SpoleRepository to use
-     */
-    @Resource(name="spoolrepository")
-    public void setSpoolRepository(SpoolRepository spool) {
-        this.spool = spool;
-    }
 
     /**
      * Set the UsersRepository to use
@@ -403,14 +391,16 @@
      */
     public void sendMail(Mail mail) throws MessagingException {
         try {
-            spool.store(mail);
+            producerTemplate.sendBody("activemq:queue:processor."+ mail.getState(), ExchangePattern.InOnly, new InMemoryMail(mail));
+            
         } catch (Exception e) {
             logger.error("Error storing message: " + e.getMessage(),e);
-            try {
+            
+            /*try {
                 spool.remove(mail);
             } catch (Exception ignored) {
                 logger.error("Error removing message after an error storing it: " + e.getMessage(),e);
-            }
+            }*/
             throw new MessagingException("Exception spooling message: " + e.getMessage(), e);
         }
         if (logger.isDebugEnabled()) {

Added: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/InMemoryMail.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/InMemoryMail.java?rev=917197&view=auto
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/InMemoryMail.java (added)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/InMemoryMail.java Sun Feb 28 16:36:41 2010
@@ -0,0 +1,80 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.transport.camel;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Properties;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.james.core.MailImpl;
+import org.apache.james.core.MimeMessageUtil;
+import org.apache.mailet.Mail;
+
+/**
+ * This is just used for the JMS spooling atm. It is super inefficient because it store the whole MimeMessage in memory.
+ * 
+ * This needs to get fixed
+ *
+ */
+public class InMemoryMail extends MailImpl {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+    private byte[] mimeMessage;
+    
+    public InMemoryMail(Mail mail) throws MessagingException {
+        super(mail);
+        setMessage(mail.getMessage());
+        
+    }
+   
+    public MimeMessage getMessage() throws MessagingException {
+        MimeMessage m = new MimeMessage(Session.getInstance(new Properties()), new ByteArrayInputStream(mimeMessage));
+        return m;
+    }
+
+    public long getMessageSize() throws MessagingException {
+        return MimeMessageUtil.calculateMessageSize(getMessage());
+    }
+
+   
+    public void setMessage(MimeMessage arg0) {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            arg0.writeTo(out);
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+     
+        mimeMessage = out.toByteArray();
+        
+        // we have the MimeMessage copied to the byte array, so time to dispose the shared stuff
+        dispose();
+   
+    }
+
+}

Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java?rev=917197&r1=917196&r2=917197&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java Sun Feb 28 16:36:41 2010
@@ -29,6 +29,7 @@
 import javax.annotation.Resource;
 import javax.mail.MessagingException;
 
+import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.model.ChoiceDefinition;
@@ -88,24 +89,28 @@
 
         Processor terminatingMailetProcessor = new MailetProcessor(new TerminatingMailet(), logger);
 
-        // start to consume from the spool
-        ChoiceDefinition spoolDef = from("spool://spoolRepository")
-       
-        // start first choice
-        .choice();
         
         List<HierarchicalConfiguration> processorConfs = config.configurationsAt("processor");
         for (int i = 0; i < processorConfs.size(); i++) {
             final HierarchicalConfiguration processorConf = processorConfs.get(i);
             String processorName = processorConf.getString("[@name]");
 
-            
+          
             processors.add(processorName);
             mailets.put(processorName, new ArrayList<Mailet>());
             matchers.put(processorName, new ArrayList<Matcher>());
 
             // Check which route we need to go
-            ChoiceDefinition processorDef = spoolDef.when(header(MailMessage.STATE).isEqualTo(processorName));
+            ChoiceDefinition processorDef = fromF("activemq:queue:processor.%s?maxConcurrentConsumers=50", processorName)
+            
+                // exchange mode is inOnly
+                .inOnly()
+                
+                // use transaction
+                .transacted()
+                
+                // check that body is not null, just to be sure...
+                .choice().when(body().isNotNull());
             
             final List<HierarchicalConfiguration> mailetConfs = processorConf.configurationsAt("mailet");
             // Loop through the mailet configuration, load
@@ -197,22 +202,23 @@
                             // start first choice
                             .choice()
                             
-                            // check if the state of the mail is the same as the
-                            // current processor. if not we have can just store it to spool an stop the route processing
-                            .when(header(MailMessage.STATE).isNotEqualTo(processorName)).to("spool://spoolRepository").stop()
-                            
-                            // if not continue the route
-                            .otherwise()
-                            
-                            // start second choice
-                            .choice()
-                            
                             // check if we need to execute the mailet. If so execute it and remove the header on the end
-                            .when(header(MatcherSplitter.MATCHER_MATCHED_HEADER).isEqualTo("true")).process(new MailetProcessor(mailet, logger)).removeHeader(MatcherSplitter.MATCHER_MATCHED_HEADER)
+                            .when(new MatcherMatch()).process(new MailetProcessor(mailet, logger))
+                                            
                             
                             // end second choice
                             .end()
                             
+                            .choice()
+               
+                            // if the mailstate is GHOST whe should just stop here.
+                            .when(new MailStateEquals(Mail.GHOST)).stop()
+                             
+                            // check if the state of the mail is the same as the
+                            // current processor. If not just route it to the right endpoint via routingSlip.
+                            // we use the routingSlip because @RecipientList not work as aspected. See https://issues.apache.org/activemq/browse/CAMEL-2507
+                            .when(new MailStateNotEquals(processorName)).process(new RoutingSlipHeaderProcessor()).routingSlip(RoutingSlipHeaderProcessor.ROUTESLIP_HEADER).stop()
+                            
                             // end first choice
                             .end()
                             
@@ -239,17 +245,18 @@
                     
                     // when the mail state did not change till yet ( the end of the route) we need to call the TerminatingMailet to
                     // make sure we don't fall into a endless loop
-                    .when(header(MailMessage.STATE).isEqualTo(processorName)).process(terminatingMailetProcessor)
+                    .when(new MailStateEquals(processorName)).process(terminatingMailetProcessor)
                     
                     // end the choice
                     .end()
                     
-                    // route everything to the spool now
-                    .to("spool://spoolRepository");
+                    // route it to the right processor
+                    // we use the routingSlip because @RecipientList not work as aspected. See https://issues.apache.org/activemq/browse/CAMEL-2507
+                    .process(new RoutingSlipHeaderProcessor()).routingSlip(RoutingSlipHeaderProcessor.ROUTESLIP_HEADER).stop();
         }
-        
     }
 
+
     /**
      * Destroy all mailets and matchers
      */

Added: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java?rev=917197&view=auto
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java (added)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java Sun Feb 28 16:36:41 2010
@@ -0,0 +1,42 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.transport.camel;
+
+import org.apache.camel.Body;
+import org.apache.camel.RecipientList;
+import org.apache.mailet.Mail;
+
+/**
+ * Route the mail to the right JMS queue depending on the state of the Mail. 
+ * 
+ * This is not used atm because of this bug:
+ * https://issues.apache.org/activemq/browse/CAMEL-2507
+ * 
+ *
+ */
+public class MailRouter {
+    
+    @RecipientList
+    public String to(@Body Mail mail) {
+        String queueName = "activemq:queue:processor."+ mail.getState();
+        return queueName;
+    }
+    
+
+}

Added: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateEquals.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateEquals.java?rev=917197&view=auto
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateEquals.java (added)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateEquals.java Sun Feb 28 16:36:41 2010
@@ -0,0 +1,49 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.transport.camel;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+import org.apache.mailet.Mail;
+
+/**
+ * Check the the Mail state is Equals to the one give on the constructor
+ * 
+ *
+ */
+public class MailStateEquals implements Predicate{
+
+    private String state;
+    public MailStateEquals(String state) {
+        this.state = state;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.camel.Predicate#matches(org.apache.camel.Exchange)
+     */
+    public boolean matches(Exchange ex) {
+        Mail m = (Mail) ex.getIn().getBody();
+        if (state.equals(m.getState())) {
+            return true;
+        }
+        return false;
+    }
+
+}

Added: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateNotEquals.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateNotEquals.java?rev=917197&view=auto
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateNotEquals.java (added)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailStateNotEquals.java Sun Feb 28 16:36:41 2010
@@ -0,0 +1,49 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.transport.camel;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+import org.apache.mailet.Mail;
+
+/**
+ * Check if the Mail state is NOT equal to the one given on the constructor
+ * 
+ *
+ */
+public class MailStateNotEquals implements Predicate{
+
+    private String state;
+    public MailStateNotEquals(String state) {
+        this.state = state;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.camel.Predicate#matches(org.apache.camel.Exchange)
+     */
+    public boolean matches(Exchange ex) {
+        Mail m = (Mail) ex.getIn().getBody();
+        if (state.equals(m.getState())) {
+            return false;
+        }
+        return true;
+    }
+
+}

Added: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherMatch.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherMatch.java?rev=917197&view=auto
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherMatch.java (added)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherMatch.java Sun Feb 28 16:36:41 2010
@@ -0,0 +1,45 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.transport.camel;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+import org.apache.mailet.Mail;
+
+/**
+ * Check if the previous called Matcher matched. This is done be
+ * checking for the present of MatcherSplitter.MATCHER_MATCHED_ATTRIBUTE attribute in the Mail
+ * 
+ *
+ */
+public class MatcherMatch implements Predicate{
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.camel.Predicate#matches(org.apache.camel.Exchange)
+     */
+    public boolean matches(Exchange arg0) {
+        Mail m = (Mail) arg0.getIn().getBody(); 
+        if (m.removeAttribute(MatcherSplitter.MATCHER_MATCHED_ATTRIBUTE) != null) {
+           return true;
+        }
+        return false;
+    }
+}

Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherSplitter.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherSplitter.java?rev=917197&r1=917196&r2=917197&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherSplitter.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MatcherSplitter.java Sun Feb 28 16:36:41 2010
@@ -28,10 +28,10 @@
 import javax.mail.MessagingException;
 
 import org.apache.camel.Body;
+import org.apache.camel.Handler;
 import org.apache.camel.InOnly;
 import org.apache.camel.Property;
 import org.apache.commons.logging.Log;
-import org.apache.james.core.MailImpl;
 import org.apache.james.transport.ProcessorUtil;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
@@ -49,7 +49,7 @@
     /**
      * Headername which is used to indicate that the matcher matched
      */
-    public final static String MATCHER_MATCHED_HEADER = "matched";
+    public final static String MATCHER_MATCHED_ATTRIBUTE = "matched";
     
     /**
      * Headername under which the matcher is stored
@@ -71,8 +71,9 @@
      * @throws MessagingException
      */
     @SuppressWarnings("unchecked")
-    public List<MailMessage> split(@Property(MATCHER_PROPERTY) Matcher matcher, @Property(ON_MATCH_EXCEPTION_PROPERTY) String onMatchException, @Property(LOGGER_PROPERTY) Log logger, @Body Mail mail) throws MessagingException {
-        List<MailMessage> mails = new ArrayList<MailMessage>();
+    @Handler
+    public List<Mail> split(@Property(MATCHER_PROPERTY) Matcher matcher, @Property(ON_MATCH_EXCEPTION_PROPERTY) String onMatchException, @Property(LOGGER_PROPERTY) Log logger, @Body Mail mail) throws MessagingException {
+        List<Mail> mails = new ArrayList<Mail>();
         boolean fullMatch = false;
         
         // call the matcher
@@ -122,28 +123,27 @@
             } else {
                 mail.setRecipients(rcpts);
                 
-                Mail newMail = new MailImpl(mail);
+                Mail newMail = new InMemoryMail(mail);
                 newMail.setRecipients(matchedRcpts);
                 
-                MailMessage newmsg = new MailMessage(newMail);
-                    
+              
                 // Set a header because the matcher matched. This can be used later when processing the route
-                newmsg.setHeader(MATCHER_MATCHED_HEADER, true);
+                newMail.setAttribute(MATCHER_MATCHED_ATTRIBUTE, true);
                 
                 // add the new generated mail to the mails list
-                mails.add(newmsg);
+                mails.add(newMail);
             }
         }
             
-        MailMessage mailMsg = new MailMessage(mail);
         if (fullMatch) {
             // Set a header because the matcher matched. This can be used later when processing the route
-            mailMsg.setHeader(MATCHER_MATCHED_HEADER, true);
+            mail.setAttribute(MATCHER_MATCHED_ATTRIBUTE, true);
         }
         
         // add mailMsg to the mails list
-        mails.add(mailMsg);
+        mails.add(mail);
         
         return mails;
     }
+
 }

Added: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/RoutingSlipHeaderProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/RoutingSlipHeaderProcessor.java?rev=917197&view=auto
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/RoutingSlipHeaderProcessor.java (added)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/RoutingSlipHeaderProcessor.java Sun Feb 28 16:36:41 2010
@@ -0,0 +1,43 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.transport.camel;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.mailet.Mail;
+
+/**
+ * Set the right header on the exchange based on the State of the Mail. This is used 
+ * later to route it to the right endpoint
+ *
+ */
+public class RoutingSlipHeaderProcessor implements Processor {
+    
+    public static final String ROUTESLIP_HEADER = "routeslipEndpoint";
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.camel.Processor#process(org.apache.camel.Exchange)
+     */
+    public void process(Exchange arg0) throws Exception {
+        arg0.getIn().setHeader(ROUTESLIP_HEADER, "activemq:queue:processor." +  ((Mail) arg0.getIn().getBody()).getState());
+    }
+   
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org