You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dm...@apache.org on 2018/06/06 15:07:57 UTC

[camel] branch master updated: CAMEL-12542:seda - Have a default queue size limit

This is an automated email from the ASF dual-hosted git repository.

dmvolod pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 9e93427  CAMEL-12542:seda - Have a default queue size limit
9e93427 is described below

commit 9e93427c2ad20ddd936dec56341891c7eb5b79b0
Author: Ramu <kk...@redhat.com>
AuthorDate: Mon Jun 4 19:51:30 2018 +0530

    CAMEL-12542:seda - Have a default queue size limit
---
 camel-core/src/main/docs/seda-component.adoc       |  2 +-
 camel-core/src/main/docs/stub-component.adoc       |  2 +-
 camel-core/src/main/docs/vm-component.adoc         |  2 +-
 .../apache/camel/component/seda/SedaComponent.java | 13 ++++++-----
 .../java/org/apache/camel/util/SedaConstants.java  | 27 ++++++++++++++++++++++
 .../seda/SameSedaQueueSizeAndNoSizeTest.java       |  6 +++--
 .../camel/component/seda/SedaConfigureTest.java    |  4 +++-
 .../seda/SedaDefaultUnboundedQueueSizeTest.java    |  4 ++--
 .../component/vm/SameVmQueueSizeAndNoSizeTest.java |  4 +++-
 .../springboot/SedaComponentConfiguration.java     |  2 +-
 .../springboot/StubComponentConfiguration.java     |  2 +-
 .../vm/springboot/VmComponentConfiguration.java    |  2 +-
 12 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/camel-core/src/main/docs/seda-component.adoc b/camel-core/src/main/docs/seda-component.adoc
index bb2ff0d..8e7fbfa 100644
--- a/camel-core/src/main/docs/seda-component.adoc
+++ b/camel-core/src/main/docs/seda-component.adoc
@@ -46,7 +46,7 @@ The SEDA component supports 5 options which are listed below.
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *queueSize* (advanced) | Sets the default maximum capacity of the SEDA queue (i.e., the number of messages it can hold). |  | int
+| *queueSize* (advanced) | Sets the default maximum capacity of the SEDA queue (i.e., the number of messages it can hold). | 1000 | int
 | *concurrentConsumers* (consumer) | Sets the default number of concurrent threads processing exchanges. | 1 | int
 | *defaultQueueFactory* (advanced) | Sets the default queue factory. |  | Exchange>
 | *defaultBlockWhenFull* (producer) | Whether a thread that sends messages to a full SEDA queue will block until the queue's capacity is no longer exhausted. By default, an exception will be thrown stating that the queue is full. By enabling this option, the calling thread will instead block and wait until the message can be accepted. | false | boolean
diff --git a/camel-core/src/main/docs/stub-component.adoc b/camel-core/src/main/docs/stub-component.adoc
index 9923274..b7bcc8c 100644
--- a/camel-core/src/main/docs/stub-component.adoc
+++ b/camel-core/src/main/docs/stub-component.adoc
@@ -36,7 +36,7 @@ The Stub component supports 5 options which are listed below.
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *queueSize* (advanced) | Sets the default maximum capacity of the SEDA queue (i.e., the number of messages it can hold). |  | int
+| *queueSize* (advanced) | Sets the default maximum capacity of the SEDA queue (i.e., the number of messages it can hold). | 1000 | int
 | *concurrentConsumers* (consumer) | Sets the default number of concurrent threads processing exchanges. | 1 | int
 | *defaultQueueFactory* (advanced) | Sets the default queue factory. |  | Exchange>
 | *defaultBlockWhenFull* (producer) | Whether a thread that sends messages to a full SEDA queue will block until the queue's capacity is no longer exhausted. By default, an exception will be thrown stating that the queue is full. By enabling this option, the calling thread will instead block and wait until the message can be accepted. | false | boolean
diff --git a/camel-core/src/main/docs/vm-component.adoc b/camel-core/src/main/docs/vm-component.adoc
index 3a04368..e7da8df 100644
--- a/camel-core/src/main/docs/vm-component.adoc
+++ b/camel-core/src/main/docs/vm-component.adoc
@@ -66,7 +66,7 @@ The VM component supports 5 options which are listed below.
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *queueSize* (advanced) | Sets the default maximum capacity of the SEDA queue (i.e., the number of messages it can hold). |  | int
+| *queueSize* (advanced) | Sets the default maximum capacity of the SEDA queue (i.e., the number of messages it can hold). | 1000 | int
 | *concurrentConsumers* (consumer) | Sets the default number of concurrent threads processing exchanges. | 1 | int
 | *defaultQueueFactory* (advanced) | Sets the default queue factory. |  | Exchange>
 | *defaultBlockWhenFull* (producer) | Whether a thread that sends messages to a full SEDA queue will block until the queue's capacity is no longer exhausted. By default, an exception will be thrown stating that the queue is full. By enabling this option, the calling thread will instead block and wait until the message can be accepted. | false | boolean
diff --git a/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java b/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java
index fdb52ef..3acc285 100644
--- a/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java
@@ -25,6 +25,7 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.UriEndpointComponent;
 import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.SedaConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,12 +36,12 @@ import org.slf4j.LoggerFactory;
  */
 public class SedaComponent extends UriEndpointComponent {
     protected final Logger log = LoggerFactory.getLogger(getClass());
-    protected final int maxConcurrentConsumers = 500;
+    protected final int maxConcurrentConsumers = SedaConstants.MAX_CONCURRENT_CONSUMERS;
 
-    @Metadata(label = "consumer", defaultValue = "1")
-    protected int concurrentConsumers = 1;
-    @Metadata(label = "advanced")
-    protected int queueSize;
+    @Metadata(label = "consumer", defaultValue = ""+SedaConstants.CONCURRENT_CONSUMERS)
+    protected int concurrentConsumers = SedaConstants.CONCURRENT_CONSUMERS;
+    @Metadata(label = "advanced", defaultValue = ""+SedaConstants.QUEUE_SIZE )
+    protected int queueSize = SedaConstants.QUEUE_SIZE;
     @Metadata(label = "advanced")
     protected BlockingQueueFactory<Exchange> defaultQueueFactory = new LinkedBlockingQueueFactory<>();
     @Metadata(label = "producer")
@@ -128,7 +129,7 @@ public class SedaComponent extends UriEndpointComponent {
             if (size != null && !size.equals(ref.getSize())) {
                 // there is already a queue, so make sure the size matches
                 throw new IllegalArgumentException("Cannot use existing queue " + key + " as the existing queue size "
-                        + (ref.getSize() != null ? ref.getSize() : Integer.MAX_VALUE) + " does not match given queue size " + size);
+                        + (ref.getSize() != null ? ref.getSize() : SedaConstants.QUEUE_SIZE) + " does not match given queue size " + size);
             }
             // add the reference before returning queue
             ref.addReference(endpoint);
diff --git a/camel-core/src/main/java/org/apache/camel/util/SedaConstants.java b/camel-core/src/main/java/org/apache/camel/util/SedaConstants.java
new file mode 100644
index 0000000..b6de163
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/SedaConstants.java
@@ -0,0 +1,27 @@
+/**
+ * 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.util;
+
+public final class SedaConstants {
+    
+    public static final int MAX_CONCURRENT_CONSUMERS = 500;
+    public static final int CONCURRENT_CONSUMERS = 1;
+    public static final int QUEUE_SIZE = 1000;
+    private SedaConstants() {
+    }
+
+}
diff --git a/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueSizeAndNoSizeTest.java b/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueSizeAndNoSizeTest.java
index 7aa0d81..9a8045b 100644
--- a/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueSizeAndNoSizeTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueSizeAndNoSizeTest.java
@@ -20,12 +20,14 @@ import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.SedaConstants;
 
 /**
  *
  */
 public class SameSedaQueueSizeAndNoSizeTest extends ContextTestSupport {
-
+    
+    
     public void testSameQueue() throws Exception {
         for (int i = 0; i < 100; i++) {
             template.sendBody("seda:foo", "" + i);
@@ -58,7 +60,7 @@ public class SameSedaQueueSizeAndNoSizeTest extends ContextTestSupport {
             fail("Should fail");
         } catch (ResolveEndpointFailedException e) {
             IllegalArgumentException ise = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
-            assertEquals("Cannot use existing queue seda://bar as the existing queue size " + Integer.MAX_VALUE + " does not match given queue size 200", ise.getMessage());
+            assertEquals("Cannot use existing queue seda://bar as the existing queue size " + SedaConstants.QUEUE_SIZE + " does not match given queue size 200", ise.getMessage());
         }
     }
 
diff --git a/camel-core/src/test/java/org/apache/camel/component/seda/SedaConfigureTest.java b/camel-core/src/test/java/org/apache/camel/component/seda/SedaConfigureTest.java
index 80fa090..c14114e 100644
--- a/camel-core/src/test/java/org/apache/camel/component/seda/SedaConfigureTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/seda/SedaConfigureTest.java
@@ -21,11 +21,13 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
+import org.apache.camel.util.SedaConstants;
 
 /**
  * @version
  */
 public class SedaConfigureTest extends ContextTestSupport {
+    
 
     @SuppressWarnings("unchecked")
     public void testBlockingQueueConfigured() throws Exception {
@@ -50,7 +52,7 @@ public class SedaConfigureTest extends ContextTestSupport {
         SedaEndpoint endpoint = resolveMandatoryEndpoint("seda:foo", SedaEndpoint.class);
         assertFalse("blockWhenFull: wrong default", endpoint.isBlockWhenFull());
         assertEquals("concurrentConsumers: wrong default", 1, endpoint.getConcurrentConsumers());
-        assertEquals("size (remainingCapacity): wrong default", Integer.MAX_VALUE, endpoint.getSize());
+        assertEquals("size (remainingCapacity): wrong default", SedaConstants.QUEUE_SIZE, endpoint.getSize());
         assertEquals("timeout: wrong default", 30000L, endpoint.getTimeout());
     }
 }
diff --git a/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultUnboundedQueueSizeTest.java b/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultUnboundedQueueSizeTest.java
index 679e372..54a059a 100644
--- a/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultUnboundedQueueSizeTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultUnboundedQueueSizeTest.java
@@ -27,11 +27,11 @@ public class SedaDefaultUnboundedQueueSizeTest extends ContextTestSupport {
         SedaEndpoint seda = context.getEndpoint("seda:foo", SedaEndpoint.class);
         assertEquals(0, seda.getQueue().size());
 
-        for (int i = 0; i < 1200; i++) {
+        for (int i = 0; i < 1000; i++) {
             template.sendBody("seda:foo", "Message " + i);
         }
 
-        assertEquals(1200, seda.getQueue().size());
+        assertEquals(1000, seda.getQueue().size());
     }
 
     public void testSedaDefaultBoundedQueueSize() throws Exception {
diff --git a/camel-core/src/test/java/org/apache/camel/component/vm/SameVmQueueSizeAndNoSizeTest.java b/camel-core/src/test/java/org/apache/camel/component/vm/SameVmQueueSizeAndNoSizeTest.java
index b2c2d01..3f9952f 100644
--- a/camel-core/src/test/java/org/apache/camel/component/vm/SameVmQueueSizeAndNoSizeTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/vm/SameVmQueueSizeAndNoSizeTest.java
@@ -20,11 +20,13 @@ import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.SedaConstants;
 
 /**
  *
  */
 public class SameVmQueueSizeAndNoSizeTest extends ContextTestSupport {
+    
 
     public void testSameQueue() throws Exception {
         for (int i = 0; i < 100; i++) {
@@ -58,7 +60,7 @@ public class SameVmQueueSizeAndNoSizeTest extends ContextTestSupport {
             fail("Should fail");
         } catch (ResolveEndpointFailedException e) {
             IllegalArgumentException ise = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
-            assertEquals("Cannot use existing queue vm://bar as the existing queue size " + Integer.MAX_VALUE + " does not match given queue size 200", ise.getMessage());
+            assertEquals("Cannot use existing queue vm://bar as the existing queue size " + SedaConstants.QUEUE_SIZE + " does not match given queue size 200", ise.getMessage());
         }
     }
 
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentConfiguration.java
index 286d693..f45a518 100644
--- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentConfiguration.java
@@ -39,7 +39,7 @@ public class SedaComponentConfiguration
      * Sets the default maximum capacity of the SEDA queue (i.e., the number of
      * messages it can hold).
      */
-    private Integer queueSize;
+    private Integer queueSize = 1000;
     /**
      * Sets the default number of concurrent threads processing exchanges.
      */
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentConfiguration.java
index 5efee17..82b5a30 100644
--- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentConfiguration.java
@@ -39,7 +39,7 @@ public class StubComponentConfiguration
      * Sets the default maximum capacity of the SEDA queue (i.e., the number of
      * messages it can hold).
      */
-    private Integer queueSize;
+    private Integer queueSize = 1000;
     /**
      * Sets the default number of concurrent threads processing exchanges.
      */
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/vm/springboot/VmComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/vm/springboot/VmComponentConfiguration.java
index b497827..17f5b4c 100644
--- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/vm/springboot/VmComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/vm/springboot/VmComponentConfiguration.java
@@ -39,7 +39,7 @@ public class VmComponentConfiguration
      * Sets the default maximum capacity of the SEDA queue (i.e., the number of
      * messages it can hold).
      */
-    private Integer queueSize;
+    private Integer queueSize = 1000;
     /**
      * Sets the default number of concurrent threads processing exchanges.
      */

-- 
To stop receiving notification emails like this one, please contact
dmvolod@apache.org.