camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1080900 - in /camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/ test/java/org/apache/camel/component/jms/
Date Sat, 12 Mar 2011 10:00:03 GMT
Author: davsclaus
Date: Sat Mar 12 10:00:03 2011
New Revision: 1080900

URL: http://svn.apache.org/viewvc?rev=1080900&view=rev
Log:
CAMEL-3782: Polished

Modified:
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsLoadBalanceFailoverWithForceSendOriginalJmsMessageTest.java

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java?rev=1080900&r1=1080899&r2=1080900&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
Sat Mar 12 10:00:03 2011
@@ -259,9 +259,10 @@ public class JmsBinding {
         Message answer = null;
 
         boolean alwaysCopy = endpoint != null && endpoint.getConfiguration().isAlwaysCopyMessage();
+        boolean force = endpoint != null && endpoint.getConfiguration().isForceSendOriginalMessage();
         if (!alwaysCopy && camelMessage instanceof JmsMessage) {
             JmsMessage jmsMessage = (JmsMessage)camelMessage;
-            if (!jmsMessage.shouldCreateNewMessage() || endpoint.getConfiguration().isForceSendOriginalMessage())
{
+            if (!jmsMessage.shouldCreateNewMessage() || force) {
                 answer = jmsMessage.getJmsMessage();
             }
         }

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java?rev=1080900&r1=1080899&r2=1080900&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
Sat Mar 12 10:00:03 2011
@@ -301,6 +301,10 @@ public class JmsComponent extends Defaul
         getConfiguration().setTestConnectionOnStartup(testConnectionOnStartup);
     }
 
+    public void setForceSendOriginalMessage(boolean forceSendOriginalMessage) {
+        getConfiguration().setForceSendOriginalMessage(forceSendOriginalMessage);
+    }
+
     public void setRequestTimeout(long requestTimeout) {
         getConfiguration().setRequestTimeout(requestTimeout);
     }

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java?rev=1080900&r1=1080899&r2=1080900&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
Sat Mar 12 10:00:03 2011
@@ -926,6 +926,16 @@ public class JmsEndpoint extends Default
         configuration.setTestConnectionOnStartup(testConnectionOnStartup);
     }
 
+    @ManagedAttribute
+    public boolean isForceSendOriginalMessage() {
+        return configuration.isForceSendOriginalMessage();
+    }
+
+    @ManagedAttribute
+    public void setForceSendOriginalMessage(boolean forceSendOriginalMessage) {
+        configuration.setForceSendOriginalMessage(forceSendOriginalMessage);
+    }
+
     @ManagedAttribute(description = "Camel id")
     public String getCamelId() {
         return getCamelContext().getName();

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsLoadBalanceFailoverWithForceSendOriginalJmsMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsLoadBalanceFailoverWithForceSendOriginalJmsMessageTest.java?rev=1080900&r1=1080899&r2=1080900&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsLoadBalanceFailoverWithForceSendOriginalJmsMessageTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsLoadBalanceFailoverWithForceSendOriginalJmsMessageTest.java
Sat Mar 12 10:00:03 2011
@@ -18,7 +18,6 @@ package org.apache.camel.component.jms;
 
 import javax.jms.ConnectionFactory;
 
-import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.command.ActiveMQTextMessage;
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
@@ -41,7 +40,6 @@ public class JmsLoadBalanceFailoverWithF
         MockEndpoint twoMock = getMockEndpoint("mock:two");
         MockEndpoint resultMock = getMockEndpoint("mock:result");
 
-        
         oneMock.expectedMessageCount(1);
         oneMock.expectedHeaderReceived("foo", "bar");
         twoMock.expectedMessageCount(1);
@@ -50,7 +48,7 @@ public class JmsLoadBalanceFailoverWithF
         resultMock.expectedMessageCount(1);
         resultMock.expectedHeaderReceived("foo", "bar");
 
-        String out = template.requestBodyAndHeader("jms:queue:start?jmsMessageType=Text&forceSendOriginalMessage="
+ forceSendOriginalMessage, "Hello World", "foo", "bar", String.class);
+        String out = template.requestBodyAndHeader("jms:queue:start", "Hello World", "foo",
"bar", String.class);
         assertEquals("Hello Back", out);
         
         assertMockEndpointsSatisfied();
@@ -79,7 +77,7 @@ public class JmsLoadBalanceFailoverWithF
         resultMock.expectedMessageCount(1);
         resultMock.expectedHeaderReceived("foo", "bar");
         
-        out = template.requestBodyAndHeader("jms:queue:start?jmsMessageType=Text&forceSendOriginalMessage="
+ forceSendOriginalMessage, "Hello World", "foo", "bar", String.class);
+        out = template.requestBodyAndHeader("jms:queue:start", "Hello World", "foo", "bar",
String.class);
         assertEquals("Bye World", out);
 
         assertMockEndpointsSatisfied();
@@ -96,21 +94,21 @@ public class JmsLoadBalanceFailoverWithF
             public void configure() throws Exception {
                 from("jms:queue:start?mapJmsMessage=false")
                     .loadBalance().failover(-1, false, true)
-                        .to("jms:queue:one?transferException=true&forceSendOriginalMessage="
+ forceSendOriginalMessage)
-                        .to("jms:queue:two?transferException=true&forceSendOriginalMessage="
+ forceSendOriginalMessage)
-                        .to("jms:queue:three?transferException=true&forceSendOriginalMessage="
+ forceSendOriginalMessage)
+                        .to("jms:queue:one?forceSendOriginalMessage=" + forceSendOriginalMessage)
+                        .to("jms:queue:two?forceSendOriginalMessage=" + forceSendOriginalMessage)
+                        .to("jms:queue:three?forceSendOriginalMessage=" + forceSendOriginalMessage)
                     .end()
                     .to("mock:result");
 
-                from("jms:queue:one?transferException=true&mapJmsMessage=false")
+                from("jms:queue:one?mapJmsMessage=false")
                     .to("mock:one")
                     .throwException(new IllegalArgumentException("Damn"));
 
-                from("jms:queue:two?transferException=true&mapJmsMessage=false")
+                from("jms:queue:two?mapJmsMessage=false")
                     .to("mock:two")
                     .transform().simple("Hello Back");
                 
-                from("jms:queue:three?transferException=true&mapJmsMessage=false")
+                from("jms:queue:three?mapJmsMessage=false")
                     .to("mock:three")
                     .transform().simple("Bye World");
             }
@@ -121,7 +119,11 @@ public class JmsLoadBalanceFailoverWithF
         CamelContext camelContext = super.createCamelContext();
 
         ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
-        camelContext.addComponent("jms", jmsComponentAutoAcknowledge(connectionFactory));
+        JmsComponent jms = jmsComponentAutoAcknowledge(connectionFactory);
+        // we want to transfer the exception
+        jms.setTransferException(true);
+
+        camelContext.addComponent("jms", jms);
 
         return camelContext;
     }



Mime
View raw message