camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r791067 - in /camel/trunk/components/camel-jms/src/test: java/org/apache/camel/component/jms/JmsRouteUsingJMSXGroupTest.java resources/org/apache/camel/component/jms/issues/camelBrokerClient.xml
Date Sat, 04 Jul 2009 06:37:53 GMT
Author: davsclaus
Date: Sat Jul  4 06:37:53 2009
New Revision: 791067

URL: http://svn.apache.org/viewvc?rev=791067&view=rev
Log:
JMSXGroupID unit testing

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingJMSXGroupTest.java
      - copied, changed from r790877, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProduerConcurrentTest.java
Modified:
    camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/camelBrokerClient.xml

Copied: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingJMSXGroupTest.java
(from r790877, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProduerConcurrentTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingJMSXGroupTest.java?p2=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingJMSXGroupTest.java&p1=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProduerConcurrentTest.java&r1=790877&r2=791067&rev=791067&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProduerConcurrentTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingJMSXGroupTest.java
Sat Jul  4 06:37:53 2009
@@ -19,33 +19,32 @@
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import javax.jms.ConnectionFactory;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
+import org.jencks.amqpool.PooledConnectionFactory;
 import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
 
 /**
  * @version $Revision$
  */
-public class JmsProduerConcurrentTest extends CamelTestSupport {
+public class JmsRouteUsingJMSXGroupTest extends CamelTestSupport {
 
     @Test
-    public void testNoConcurrentProducers() throws Exception {
+    public void testNoConcurrentProducersJMSXGroupID() throws Exception {
         doSendMessages(1, 1);
     }
 
     @Test
-    public void testConcurrentProducers() throws Exception {
-        doSendMessages(10, 5);
+    public void testConcurrentProducersJMSXGroupID() throws Exception {
+        doSendMessages(10, 1);
     }
 
     private void doSendMessages(int files, int poolSize) throws Exception {
-        getMockEndpoint("mock:result").expectedMessageCount(files);
+        getMockEndpoint("mock:result").expectedMessageCount(files * 2);
         getMockEndpoint("mock:result").expectsNoDuplicates(body());
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
@@ -53,7 +52,9 @@
             final int index = i;
             executor.submit(new Callable<Object>() {
                 public Object call() throws Exception {
-                    template.sendBody("direct:start", "Message " + index);
+                    template.sendBodyAndHeader("direct:start", "IBM: " + index, "JMSXGroupID",
"IBM");
+                    template.sendBodyAndHeader("direct:start", "SUN: " + index, "JMSXGroupID",
"SUN");
+
                     return null;
                 }
             });
@@ -65,8 +66,10 @@
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
 
-        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
-        camelContext.addComponent("jms", jmsComponentClientAcknowledge(connectionFactory));
+        PooledConnectionFactory pool = new PooledConnectionFactory(new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"));
+        pool.setMaxConnections(10);
+
+        camelContext.addComponent("jms", jmsComponentClientAcknowledge(pool));
 
         return camelContext;
     }
@@ -78,9 +81,9 @@
             public void configure() throws Exception {
                 from("direct:start").to("jms:queue:foo");
 
-                from("jms:queue:foo").to("mock:result");
+                from("jms:queue:foo?concurrentConsumers=2").to("log:foo?showHeaders=false").to("mock:result");
             }
         };
     }
-    
-}
+
+}
\ No newline at end of file

Modified: camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/camelBrokerClient.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/camelBrokerClient.xml?rev=791067&r1=791066&r2=791067&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/camelBrokerClient.xml
(original)
+++ camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/camelBrokerClient.xml
Sat Jul  4 06:37:53 2009
@@ -27,12 +27,23 @@
     </camelContext>
 
     <!-- use jencks connection pooling so its more effecient to send JMS messages -->
-    <amqpool:pool id="jmsConnectionFactory" xmlns:amqpool="http://jencks.org/amqpool/2.0"
-                  brokerURL="tcp://localhost:61616"
-                  maxConnections="8"/>
+    <!--<amqpool:pool id="jmsConnectionFactory" xmlns:amqpool="http://jencks.org/amqpool/2.0"-->
+                  <!--brokerURL="tcp://localhost:61616"-->
+                  <!--maxConnections="8"/>-->
+
+    <!-- another pool supplied by Dejan -->
+    <bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
+        <property name="connectionFactory">
+            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
+                <property name="brokerURL" value="tcp://localhost:61616"/>
+            </bean>
+        </property>
+        <property name="maxConnections" value="8"/>
+    </bean>
+
 
     <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
-        <property name="connectionFactory" ref="jmsConnectionFactory"/>
+        <property name="connectionFactory" ref="jmsFactory"/>
         <property name="transacted" value="false"/>
         <property name="concurrentConsumers" value="10"/>
     </bean>



Mime
View raw message