camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1395883 - in /camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/JmsEndpoint.java test/java/org/apache/camel/component/jms/JmsMultipleConsumersTest.java
Date Tue, 09 Oct 2012 07:38:24 GMT
Author: davsclaus
Date: Tue Oct  9 07:38:24 2012
New Revision: 1395883

URL: http://svn.apache.org/viewvc?rev=1395883&view=rev
Log:
CAMEL-5694: JMS endpoint should allow mutiple consumers, so 2+ routes can consume from the
same queue.

Modified:
    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/JmsMultipleConsumersTest.java

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=1395883&r1=1395882&r2=1395883&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
Tue Oct  9 07:38:24 2012
@@ -267,8 +267,8 @@ public class JmsEndpoint extends Default
     }
 
     public boolean isMultipleConsumersSupported() {
-        // only allow multiple consumers for pub sub domain (e.g. topics)
-        return isPubSubDomain();
+        // JMS allows multiple consumers on both queues and topics
+        return true;
     }
 
     // Properties

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsMultipleConsumersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsMultipleConsumersTest.java?rev=1395883&r1=1395882&r2=1395883&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsMultipleConsumersTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsMultipleConsumersTest.java
Tue Oct  9 07:38:24 2012
@@ -19,10 +19,8 @@ package org.apache.camel.component.jms;
 import javax.jms.ConnectionFactory;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.FailedToStartRouteException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
-
 import org.junit.Test;
 
 import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
@@ -33,7 +31,7 @@ import static org.apache.camel.component
 public class JmsMultipleConsumersTest extends CamelTestSupport {
 
     @Test
-    public void testMultipleConsumersAllowed() throws Exception {
+    public void testMultipleConsumersTopic() throws Exception {
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
@@ -59,23 +57,26 @@ public class JmsMultipleConsumersTest ex
     }
 
     @Test
-    public void testMultipleConsumersNotAllowed() throws Exception {
+    public void testMultipleConsumersQueue() throws Exception {
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jms:queue:foo").to("mock:foo");
+                from("jms:queue:foo").to("mock:result");
 
                 from("direct:start").to("mock:result");
 
-                from("jms:queue:foo").to("mock:bar");
+                from("jms:queue:foo").to("mock:result");
             }
         });
-        try {
-            context.start();
-            fail("Should have thrown an exception");
-        } catch (FailedToStartRouteException e) {
-            assertTrue(e.getMessage().endsWith("Multiple consumers for the same endpoint
is not allowed: Endpoint[jms://queue:foo]"));
-        }
+
+        context.start();
+
+        getMockEndpoint("mock:result").expectedMessageCount(2);
+
+        template.sendBody("jms:queue:foo", "Hello World");
+        template.sendBody("jms:queue:foo", "Bye World");
+
+        assertMockEndpointsSatisfied();
     }
 
     protected CamelContext createCamelContext() throws Exception {



Mime
View raw message