servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bsny...@apache.org
Subject svn commit: r635013 - /servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java
Date Sat, 08 Mar 2008 16:59:44 GMT
Author: bsnyder
Date: Sat Mar  8 08:59:43 2008
New Revision: 635013

URL: http://svn.apache.org/viewvc?rev=635013&view=rev
Log:
SM-1219 - camel pipeline does not copy over properties

Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java?rev=635013&r1=635012&r2=635013&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/ToJbiProcessor.java
Sat Mar  8 08:59:43 2008
@@ -18,6 +18,7 @@
 
 import java.net.URISyntaxException;
 import java.util.Map;
+import java.util.Set;
 
 import javax.jbi.component.ComponentContext;
 import javax.jbi.messaging.DeliveryChannel;
@@ -25,8 +26,10 @@
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessageExchangeFactory;
 import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.util.URISupport;
 import org.apache.servicemix.jbi.resolver.URIResolver;
@@ -66,6 +69,22 @@
         }
     }
 
+    private void addHeaders(MessageExchange messageExchange, Exchange camelExchange) {
+        Set entries = messageExchange.getPropertyNames();
+        for (Object o : entries) {
+            String key = o.toString();
+            camelExchange.setProperty(key, messageExchange.getProperty(key));
+        }
+    }
+
+    private void addHeaders(NormalizedMessage normalizedMessage, Message camelMessage) {
+        Set entries = normalizedMessage.getPropertyNames();
+        for (Object o : entries) {
+            String key = o.toString();
+            camelMessage.setHeader(key, normalizedMessage.getProperty(key));
+        }
+    }
+
     public void process(Exchange exchange) {
         try {
             DeliveryChannel deliveryChannel = componentContext.getDeliveryChannel();
@@ -78,10 +97,13 @@
             if (messageExchange.getStatus() == ExchangeStatus.ERROR) {
                 exchange.setException(messageExchange.getError());
             } else if (messageExchange.getStatus() == ExchangeStatus.ACTIVE) {
+                addHeaders(messageExchange, exchange);
                 if (messageExchange.getFault() != null) {
                     exchange.getFault().setBody(messageExchange.getFault().getContent());
+                    addHeaders(messageExchange.getFault(), exchange.getFault());
                 } else {
                     exchange.getOut().setBody(messageExchange.getMessage("out").getContent());
+                    addHeaders(messageExchange.getMessage("out"), exchange.getOut());
                 }
                 messageExchange.setStatus(ExchangeStatus.DONE);
                 deliveryChannel.send(messageExchange);



Mime
View raw message