CAMEL-6545 Fixed the VM component tests errors
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ba9e189d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ba9e189d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ba9e189d Branch: refs/heads/master Commit: ba9e189d7c027131cef2f143da1422a32464ebd6 Parents: 11e954f Author: Willem Jiang <ningji...@apache.org> Authored: Thu Aug 22 09:58:33 2013 +0800 Committer: Willem Jiang <ningji...@apache.org> Committed: Thu Aug 22 09:58:33 2013 +0800 ---------------------------------------------------------------------- .../java/org/apache/camel/component/seda/QueueReference.java | 4 ++++ .../java/org/apache/camel/component/seda/SedaComponent.java | 8 +++++--- .../main/java/org/apache/camel/component/vm/VmComponent.java | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/ba9e189d/camel-core/src/main/java/org/apache/camel/component/seda/QueueReference.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/seda/QueueReference.java b/camel-core/src/main/java/org/apache/camel/component/seda/QueueReference.java index 5b7fd50..17a03cd 100644 --- a/camel-core/src/main/java/org/apache/camel/component/seda/QueueReference.java +++ b/camel-core/src/main/java/org/apache/camel/component/seda/QueueReference.java @@ -45,6 +45,10 @@ public final class QueueReference { synchronized void addReference(SedaEndpoint endpoint) { if (!endpoints.contains(endpoint)) { endpoints.add(endpoint); + // update the multipleConsumers setting if need + if (endpoint.isMultipleConsumers()) { + multipleConsumers = true; + } } } http://git-wip-us.apache.org/repos/asf/camel/blob/ba9e189d/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java ---------------------------------------------------------------------- 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 64415b3..94623f8 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 @@ -82,7 +82,7 @@ public class SedaComponent extends UriEndpointComponent { return getOrCreateQueue(endpoint, size, multipleConsumers, null); } - public synchronized QueueReference getOrCreateQueue(SedaEndpoint endpoint, Integer size, Boolean multipleConsumers, BlockingQueueFactory customQueueFactory) { + public synchronized QueueReference getOrCreateQueue(SedaEndpoint endpoint, Integer size, Boolean multipleConsumers, BlockingQueueFactory<Exchange> customQueueFactory) { String key = getQueueKey(endpoint.getEndpointUri()); QueueReference ref = getQueues().get(key); @@ -126,7 +126,7 @@ public class SedaComponent extends UriEndpointComponent { return ref; } - public synchronized QueueReference registerQueue(SedaEndpoint endpoint, BlockingQueue queue) { + public synchronized QueueReference registerQueue(SedaEndpoint endpoint, BlockingQueue<Exchange> queue) { String key = getQueueKey(endpoint.getEndpointUri()); QueueReference ref = getQueues().get(key); @@ -198,12 +198,14 @@ public class SedaComponent extends UriEndpointComponent { // we need to remove the endpoint from the reference counter String key = getQueueKey(endpoint.getEndpointUri()); QueueReference ref = getQueues().get(key); - if (ref != null) { + if (ref != null && endpoint.getConsumers().size() == 0) { + // only remove the endpoint when the consumers are removed ref.removeReference(endpoint); if (ref.getCount() <= 0) { // reference no longer needed so remove from queues getQueues().remove(key); } + } } http://git-wip-us.apache.org/repos/asf/camel/blob/ba9e189d/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java b/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java index 392d3c1..65c0836 100644 --- a/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java +++ b/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java @@ -40,6 +40,11 @@ public class VmComponent extends SedaComponent { public Map<String, QueueReference> getQueues() { return QUEUES; } + + @Override + public QueueReference getQueueReference(String key) { + return QUEUES.get(key); + } @Override protected void doStart() throws Exception {