Author: gnodet
Date: Mon Nov  3 05:13:13 2008
New Revision: 710052

URL: http://svn.apache.org/viewvc?rev=710052&view=rev
Log:
SM-1536: EIP pipeline with 'sendFaultsToTarget = true' does not copy properties 
and attachments to target ME 'in' message for a fault

Modified:
    
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java
    
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/BaseAbstractAggregatorTest.java

Modified: 
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java?rev=710052&r1=710051&r2=710052&view=diff
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java
 (original)
+++ 
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java
 Mon Nov  3 05:13:13 2008
@@ -24,6 +24,8 @@
 import javax.jbi.messaging.InOnly;
 import javax.jbi.messaging.InOut;
 import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
 import javax.jbi.messaging.RobustInOnly;
 import javax.wsdl.Definition;
 
@@ -91,6 +93,16 @@
     private String correlationTarget;
 
     /**
+     * Should message properties be copied ?
+     */
+    private boolean copyProperties;
+
+    /**
+     * Should message attachments be copied ?
+     */
+    private boolean copyAttachments;
+
+    /**
      * @return Returns the target.
      */
     public ExchangeTarget getTarget() {
@@ -146,6 +158,22 @@
         this.transformer = transformer;
     }
 
+    public boolean isCopyProperties() {
+        return copyProperties;
+    }
+
+    public void setCopyProperties(boolean copyProperties) {
+        this.copyProperties = copyProperties;
+    }
+
+    public boolean isCopyAttachments() {
+        return copyAttachments;
+    }
+
+    public void setCopyAttachments(boolean copyAttachments) {
+        this.copyAttachments = copyAttachments;
+    }
+
     /* (non-Javadoc)
      * @see org.apache.servicemix.eip.EIPEndpoint#validate()
      */
@@ -197,6 +225,7 @@
             MessageExchange me = 
getExchangeFactory().createExchange(exchange.getPattern());
             target.configureTarget(me, getContext());
             MessageUtil.transferOutToIn(tme, me);
+            copyPropertiesAndAttachments(exchange.getMessage("in"), 
me.getMessage("in"));
             sendSync(me);
             done(tme);
             if (me.getStatus() == ExchangeStatus.DONE) {
@@ -229,6 +258,7 @@
             MessageExchange me = 
getExchangeFactory().createExchange(exchange.getPattern());
             (faultsTarget != null ? faultsTarget : target).configureTarget(me, 
getContext());
             MessageUtil.transferToIn(tme.getFault(), me);
+            copyPropertiesAndAttachments(exchange.getMessage("in"), 
me.getMessage("in"));
             sendSync(me);
             done(tme);
             if (me.getStatus() == ExchangeStatus.DONE) {
@@ -362,6 +392,7 @@
                 me.setProperty(correlationTransformer, 
exchange.getExchangeId());
                 store.store(exchange.getExchangeId(), exchange);
                 MessageUtil.transferToIn(exchange.getFault(), me);
+                copyPropertiesAndAttachments(exchange.getMessage("in"), 
me.getMessage("in"));
                 send(me);
             // Faults must be sent back to the consumer
             } else {
@@ -391,6 +422,15 @@
             me.setProperty(correlationTransformer, exchange.getExchangeId());
             store.store(exchange.getExchangeId(), exchange);
             MessageUtil.transferOutToIn(exchange, me);
+            if (copyProperties || copyAttachments) {
+                MessageExchange cme = (MessageExchange) store.load(consumerId);
+                if (cme != null) {
+                    NormalizedMessage cmeInMsg = cme.getMessage("in");
+                    NormalizedMessage meInMsg = me.getMessage("in");
+                    copyPropertiesAndAttachments(cmeInMsg, meInMsg);
+                    store.store(consumerId, cme);
+                }
+            }
             send(me);
         // This should not happen
         } else {
@@ -453,4 +493,20 @@
         return rc;
     }
 
+    /**
+     * Copies properties and attachments from one message to another
+     * depending on the endpoint configuration
+     *
+     * @param from the message containing the properties and attachments
+     * @param to the destination message where the properties and attachments 
are set
+     */
+    private void copyPropertiesAndAttachments(NormalizedMessage from, 
NormalizedMessage to) throws MessagingException {
+        if (copyProperties) {
+            copyProperties(from, to);
+        }
+        if (copyAttachments) {
+            copyAttachments(from, to);
+        }
+    }
+
 }

Modified: 
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/BaseAbstractAggregatorTest.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/BaseAbstractAggregatorTest.java?rev=710052&r1=710051&r2=710052&view=diff
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/BaseAbstractAggregatorTest.java
 (original)
+++ 
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/BaseAbstractAggregatorTest.java
 Mon Nov  3 05:13:13 2008
@@ -18,6 +18,7 @@
 
 import java.util.Date;
 
+import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessageExchange.Role;
 import javax.jbi.messaging.MessagingException;
@@ -86,6 +87,7 @@
 
     private MessageExchange createExchange() throws MessagingException {
         MockMessageExchange me = 
(MockMessageExchange)factory.createExchange(JbiConstants.IN_ONLY);
+        me.setStatus(ExchangeStatus.ACTIVE);
         me.setRole(Role.PROVIDER);
         NormalizedMessage message = new MockNormalizedMessage();
         message.setContent(new StringSource("<test/>"));


Reply via email to