camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1058906 - in /camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/ main/java/org/apache/camel/component/jms/reply/ test/java/org/apache/camel/component/jms/
Date Fri, 14 Jan 2011 09:13:09 GMT
Author: davsclaus
Date: Fri Jan 14 09:13:09 2011
New Revision: 1058906

URL: http://svn.apache.org/viewvc?rev=1058906&view=rev
Log:
Added unit test for FAQ.

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyProcessRepliesConcurrentUsingThreadsTest.java
Modified:
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java?rev=1058906&r1=1058905&r2=1058906&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
Fri Jan 14 09:13:09 2011
@@ -36,7 +36,6 @@ import org.apache.camel.util.ObjectHelpe
 import org.apache.camel.util.ValueHolder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.springframework.jms.core.JmsOperations;
 import org.springframework.jms.core.MessageCreator;
 
@@ -68,16 +67,10 @@ public class JmsProducer extends Default
                 try {
                     if (endpoint.getReplyTo() != null) {
                         replyManager = endpoint.getReplyManager(endpoint.getReplyTo());
-                        if (LOG.isInfoEnabled()) {
-                            LOG.info("Using JmsReplyManager: " + replyManager + " to process
replies from: " + endpoint.getReplyTo()
-                                    + " queue with " + endpoint.getConcurrentConsumers()
+ " concurrent consumers.");
-                        }
+                        LOG.info("Using JmsReplyManager: " + replyManager + " to process
replies from: " + endpoint.getReplyTo());
                     } else {
                         replyManager = endpoint.getReplyManager();
-                        if (LOG.isInfoEnabled()) {
-                            LOG.info("Using JmsReplyManager: " + replyManager + " to process
replies from temporary queue with "
-                                    + endpoint.getConcurrentConsumers() + " concurrent consumers.");
-                        }
+                        LOG.info("Using JmsReplyManager: " + replyManager + " to process
replies from temporary queue");
                     }
                 } catch (Exception e) {
                     throw new FailedToCreateProducerException(endpoint, e);

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java?rev=1058906&r1=1058905&r2=1058906&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java
Fri Jan 14 09:13:09 2011
@@ -200,6 +200,7 @@ public abstract class ReplyManagerSuppor
         // create JMS listener and start it
         listenerContainer = createListenerContainer();
         listenerContainer.afterPropertiesSet();
+        log.info("Starting reply listener container on endpoint: " + endpoint);
         listenerContainer.start();
     }
 
@@ -208,6 +209,7 @@ public abstract class ReplyManagerSuppor
         ServiceHelper.stopService(correlation);
 
         if (listenerContainer != null) {
+            log.info("Stopping reply listener container on endpoint: " + endpoint);
             listenerContainer.stop();
             listenerContainer.destroy();
             listenerContainer = null;

Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyProcessRepliesConcurrentUsingThreadsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyProcessRepliesConcurrentUsingThreadsTest.java?rev=1058906&view=auto
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyProcessRepliesConcurrentUsingThreadsTest.java
(added)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyProcessRepliesConcurrentUsingThreadsTest.java
Fri Jan 14 09:13:09 2011
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jms;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+/**
+ * @version $Revision$
+ */
+public class JmsRequestReplyProcessRepliesConcurrentUsingThreadsTest extends CamelTestSupport
{
+
+    protected String componentName = "activemq";
+
+    @Test
+    public void testRequestReplyWithConcurrent() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(5);
+
+        log.info("Sending messages ...");
+        template.sendBody("seda:start", "A");
+        template.sendBody("seda:start", "B");
+        template.sendBody("seda:start", "C");
+        template.sendBody("seda:start", "D");
+        template.sendBody("seda:start", "E");
+        log.info("... done sending messages");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+        camelContext.addComponent(componentName, jmsComponentAutoAcknowledge(connectionFactory));
+
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:start")
+                    .inOut().to("activemq:queue:foo")
+                    .threads(5)
+                    .log("reply   - ${body}")
+                    .delay(2000)
+                    .log("done    - ${body}")
+                    .to("mock:result");
+
+                from("activemq:queue:foo")
+                    .log("request - ${body}")
+                    .transform(body().prepend("Bye "))
+                    .to("mock:bye");
+            }
+        };
+    }
+}
+
+



Mime
View raw message