camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject svn commit: r1359226 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/component/seda/SedaEndpoint.java main/java/org/apache/camel/component/seda/SedaProducer.java test/java/org/apache/camel/component/seda/SedaRemoveRouteThenAddItAgainTest.java
Date Mon, 09 Jul 2012 15:42:40 GMT
Author: bvahdat
Date: Mon Jul  9 15:42:40 2012
New Revision: 1359226

URL: http://svn.apache.org/viewvc?rev=1359226&view=rev
Log:
CAMEL-5432: SedaProducer should send to the right BlockingQueue being attached on the SedaEndpoint
so that the sent messages don't get lost.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaRemoveRouteThenAddItAgainTest.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java?rev=1359226&r1=1359225&r2=1359226&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
Mon Jul  9 15:42:40 2012
@@ -85,7 +85,7 @@ public class SedaEndpoint extends Defaul
     }
 
     public Producer createProducer() throws Exception {
-        return new SedaProducer(this, getQueue(), getWaitForTaskToComplete(), getTimeout(),
isBlockWhenFull());
+        return new SedaProducer(this, getWaitForTaskToComplete(), getTimeout(), isBlockWhenFull());
     }
 
     public Consumer createConsumer(Processor processor) throws Exception {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java?rev=1359226&r1=1359225&r2=1359226&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
Mon Jul  9 15:42:40 2012
@@ -32,6 +32,10 @@ import org.apache.camel.util.ExchangeHel
  * @version 
  */
 public class SedaProducer extends DefaultAsyncProducer {
+    /**
+     * @deprecated Better make use of the {@link SedaEndpoint#getQueue()} API which delivers
the accurate reference to the queue currently being used.
+     */
+    @Deprecated
     protected final BlockingQueue<Exchange> queue;
     private final SedaEndpoint endpoint;
     private final WaitForTaskToComplete waitForTaskToComplete;
@@ -39,17 +43,24 @@ public class SedaProducer extends Defaul
     private final boolean blockWhenFull;
 
     /**
-     * @deprecated use the other constructor
+     * @deprecated Use {@link #SedaProducer(SedaEndpoint, WaitForTaskToComplete, long, boolean)
the other constructor}.
      */
     @Deprecated
     public SedaProducer(SedaEndpoint endpoint, BlockingQueue<Exchange> queue, WaitForTaskToComplete
waitForTaskToComplete, long timeout) {
-        this(endpoint, queue, waitForTaskToComplete, timeout, false);
+        this(endpoint, waitForTaskToComplete, timeout, false);
     }
-    
-    public SedaProducer(SedaEndpoint endpoint, BlockingQueue<Exchange> queue, WaitForTaskToComplete
waitForTaskToComplete,
-                        long timeout, boolean blockWhenFull) {
+
+    /**
+     * @deprecated Use {@link #SedaProducer(SedaEndpoint, WaitForTaskToComplete, long, boolean)
the other constructor}.
+     */
+    @Deprecated
+    public SedaProducer(SedaEndpoint endpoint, BlockingQueue<Exchange> queue, WaitForTaskToComplete
waitForTaskToComplete, long timeout, boolean blockWhenFull) {
+        this(endpoint, waitForTaskToComplete, timeout, blockWhenFull);
+    }
+
+    public SedaProducer(SedaEndpoint endpoint, WaitForTaskToComplete waitForTaskToComplete,
long timeout, boolean blockWhenFull) {
         super(endpoint);
-        this.queue = queue;
+        this.queue = endpoint.getQueue();
         this.endpoint = endpoint;
         this.waitForTaskToComplete = waitForTaskToComplete;
         this.timeout = timeout;
@@ -125,7 +136,7 @@ public class SedaProducer extends Defaul
                 if (!done) {
                     exchange.setException(new ExchangeTimedOutException(exchange, timeout));
                     // remove timed out Exchange from queue
-                    queue.remove(copy);
+                    endpoint.getQueue().remove(copy);
                     // count down to indicate timeout
                     latch.countDown();
                 }
@@ -183,6 +194,7 @@ public class SedaProducer extends Defaul
      * @param exchange the exchange to add to the queue
      */
     protected void addToQueue(Exchange exchange) {
+        BlockingQueue<Exchange> queue = endpoint.getQueue();
         if (blockWhenFull) {
             try {
                 queue.put(exchange);

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaRemoveRouteThenAddItAgainTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaRemoveRouteThenAddItAgainTest.java?rev=1359226&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaRemoveRouteThenAddItAgainTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaRemoveRouteThenAddItAgainTest.java
Mon Jul  9 15:42:40 2012
@@ -0,0 +1,59 @@
+/**
+ * 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.seda;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version
+ */
+public class SedaRemoveRouteThenAddItAgainTest extends ContextTestSupport {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() throws Exception {
+                from("seda:in").id("sedaToMock").to("mock:out");
+            }
+        };
+    }
+
+    public void testRemoveRouteAndThenAddItAgain() throws Exception {
+        MockEndpoint out = getMockEndpoint("mock:out");
+        out.expectedMessageCount(1);
+
+        template.sendBody("seda:in", "Test Message");
+
+        out.assertIsSatisfied();
+
+        out.reset();
+
+        context.stopRoute("sedaToMock");
+        context.removeRoute("sedaToMock");
+        context.addRoutes(createRouteBuilder());
+
+        out.expectedMessageCount(1);
+
+        template.sendBody("seda:in", "Test Message");
+
+        out.assertIsSatisfied();
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaRemoveRouteThenAddItAgainTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message