You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/08/12 10:39:20 UTC
[1/3] git commit: CAMEL-7649: camel-jms - The QueueBrowseStrategy
need support for JMS Selector.
Repository: camel
Updated Branches:
refs/heads/camel-2.13.x 58c983ecb -> 9a4eb50ff
refs/heads/master 759a4d62b -> 5a5f66155
CAMEL-7649: camel-jms - The QueueBrowseStrategy need support for JMS Selector.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9a4eb50f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9a4eb50f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9a4eb50f
Branch: refs/heads/camel-2.13.x
Commit: 9a4eb50ff1f39f1c68eaf365778db6d61f4d6bc9
Parents: 6ce0774
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Aug 12 10:37:34 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 12 10:39:03 2014 +0200
----------------------------------------------------------------------
.../jms/DefaultQueueBrowseStrategy.java | 76 ++++++++++----------
.../camel/component/jms/JmsQueueEndpoint.java | 6 +-
.../component/jms/QueueBrowseStrategy.java | 2 -
3 files changed, 39 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9a4eb50f/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
index f5cb164..3258d61 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
@@ -37,47 +37,47 @@ import org.springframework.jms.core.JmsOperations;
public class DefaultQueueBrowseStrategy implements QueueBrowseStrategy {
public List<Exchange> browse(JmsOperations template, String queue, final JmsQueueEndpoint endpoint) {
- return template.browse(queue, new BrowserCallback<List<Exchange>>() {
- public List<Exchange> doInJms(Session session, QueueBrowser browser) throws JMSException {
- int size = endpoint.getMaximumBrowseSize();
- if (size <= 0) {
- size = Integer.MAX_VALUE;
- }
+ if (endpoint.getSelector() != null) {
+ return template.browseSelected(queue, endpoint.getSelector(), new BrowserCallback<List<Exchange>>() {
+ public List<Exchange> doInJms(Session session, QueueBrowser browser) throws JMSException {
+ int size = endpoint.getMaximumBrowseSize();
+ if (size <= 0) {
+ size = Integer.MAX_VALUE;
+ }
- // not the best implementation in the world as we have to browse
- // the entire queue, which could be massive
- List<Exchange> answer = new ArrayList<Exchange>();
- Enumeration<?> iter = browser.getEnumeration();
- for (int i = 0; i < size && iter.hasMoreElements(); i++) {
- Message message = (Message) iter.nextElement();
- Exchange exchange = endpoint.createExchange(message);
- answer.add(exchange);
+ // not the best implementation in the world as we have to browse
+ // the entire queue, which could be massive
+ List<Exchange> answer = new ArrayList<Exchange>();
+ Enumeration<?> iter = browser.getEnumeration();
+ for (int i = 0; i < size && iter.hasMoreElements(); i++) {
+ Message message = (Message) iter.nextElement();
+ Exchange exchange = endpoint.createExchange(message);
+ answer.add(exchange);
+ }
+ return answer;
}
- return answer;
- }
- });
- }
+ });
+ } else {
+ return template.browse(queue, new BrowserCallback<List<Exchange>>() {
+ public List<Exchange> doInJms(Session session, QueueBrowser browser) throws JMSException {
+ int size = endpoint.getMaximumBrowseSize();
+ if (size <= 0) {
+ size = Integer.MAX_VALUE;
+ }
- @Override
- public List<Exchange> browseSelected(final String selector, final JmsOperations template, final String queue, final JmsQueueEndpoint endpoint) {
- return template.browseSelected(queue, selector, new BrowserCallback<List<Exchange>>() {
- public List<Exchange> doInJms(Session session, QueueBrowser browser) throws JMSException {
- int size = endpoint.getMaximumBrowseSize();
- if (size <= 0) {
- size = Integer.MAX_VALUE;
+ // not the best implementation in the world as we have to browse
+ // the entire queue, which could be massive
+ List<Exchange> answer = new ArrayList<Exchange>();
+ Enumeration<?> iter = browser.getEnumeration();
+ for (int i = 0; i < size && iter.hasMoreElements(); i++) {
+ Message message = (Message) iter.nextElement();
+ Exchange exchange = endpoint.createExchange(message);
+ answer.add(exchange);
+ }
+ return answer;
}
-
- // not the best implementation in the world as we have to browse
- // the entire queue, which could be massive
- List<Exchange> answer = new ArrayList<Exchange>();
- Enumeration<?> iter = browser.getEnumeration();
- for (int i = 0; i < size && iter.hasMoreElements(); i++) {
- Message message = (Message) iter.nextElement();
- Exchange exchange = endpoint.createExchange(message);
- answer.add(exchange);
- }
- return answer;
- }
- });
+ });
+ }
}
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/9a4eb50f/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
index e71c577..cafc1c1 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
@@ -95,11 +95,7 @@ public class JmsQueueEndpoint extends JmsEndpoint implements BrowsableEndpoint {
}
String queue = getDestinationName();
JmsOperations template = getConfiguration().createInOnlyTemplate(this, false, queue);
- if (getSelector() != null) {
- return queueBrowseStrategy.browseSelected(getSelector(), template, queue, this);
- } else {
- return queueBrowseStrategy.browse(template, queue, this);
- }
+ return queueBrowseStrategy.browse(template, queue, this);
}
@ManagedOperation(description = "Current number of Exchanges in Queue")
http://git-wip-us.apache.org/repos/asf/camel/blob/9a4eb50f/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
index 44727a2..d973206 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
@@ -28,6 +28,4 @@ public interface QueueBrowseStrategy {
List<Exchange> browse(JmsOperations template, String queue, JmsQueueEndpoint endpoint);
- List<Exchange> browseSelected(String selector, JmsOperations template, String queue, JmsQueueEndpoint endpoint);
-
}
[2/3] git commit: CAMEL-7649: camel-jms - The QueueBrowseStrategy
need support for JMS Selector
Posted by da...@apache.org.
CAMEL-7649: camel-jms - The QueueBrowseStrategy need support for JMS Selector
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6ce07743
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6ce07743
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6ce07743
Branch: refs/heads/camel-2.13.x
Commit: 6ce077438652e241e2f463a486f1e88630fd8de8
Parents: 58c983e
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jul 30 16:43:16 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 12 10:39:03 2014 +0200
----------------------------------------------------------------------
.../jms/DefaultQueueBrowseStrategy.java | 23 ++++++++++++++++++++
.../camel/component/jms/JmsQueueEndpoint.java | 6 ++++-
.../component/jms/QueueBrowseStrategy.java | 2 ++
.../camel/component/jms/JmsSelectorInTest.java | 6 ++++-
4 files changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6ce07743/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
index e337e4f..f5cb164 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
@@ -57,4 +57,27 @@ public class DefaultQueueBrowseStrategy implements QueueBrowseStrategy {
}
});
}
+
+ @Override
+ public List<Exchange> browseSelected(final String selector, final JmsOperations template, final String queue, final JmsQueueEndpoint endpoint) {
+ return template.browseSelected(queue, selector, new BrowserCallback<List<Exchange>>() {
+ public List<Exchange> doInJms(Session session, QueueBrowser browser) throws JMSException {
+ int size = endpoint.getMaximumBrowseSize();
+ if (size <= 0) {
+ size = Integer.MAX_VALUE;
+ }
+
+ // not the best implementation in the world as we have to browse
+ // the entire queue, which could be massive
+ List<Exchange> answer = new ArrayList<Exchange>();
+ Enumeration<?> iter = browser.getEnumeration();
+ for (int i = 0; i < size && iter.hasMoreElements(); i++) {
+ Message message = (Message) iter.nextElement();
+ Exchange exchange = endpoint.createExchange(message);
+ answer.add(exchange);
+ }
+ return answer;
+ }
+ });
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/6ce07743/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
index cafc1c1..e71c577 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
@@ -95,7 +95,11 @@ public class JmsQueueEndpoint extends JmsEndpoint implements BrowsableEndpoint {
}
String queue = getDestinationName();
JmsOperations template = getConfiguration().createInOnlyTemplate(this, false, queue);
- return queueBrowseStrategy.browse(template, queue, this);
+ if (getSelector() != null) {
+ return queueBrowseStrategy.browseSelected(getSelector(), template, queue, this);
+ } else {
+ return queueBrowseStrategy.browse(template, queue, this);
+ }
}
@ManagedOperation(description = "Current number of Exchanges in Queue")
http://git-wip-us.apache.org/repos/asf/camel/blob/6ce07743/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
index d973206..44727a2 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
@@ -28,4 +28,6 @@ public interface QueueBrowseStrategy {
List<Exchange> browse(JmsOperations template, String queue, JmsQueueEndpoint endpoint);
+ List<Exchange> browseSelected(String selector, JmsOperations template, String queue, JmsQueueEndpoint endpoint);
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/6ce07743/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSelectorInTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSelectorInTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSelectorInTest.java
index 183cc57..00f3482 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSelectorInTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSelectorInTest.java
@@ -41,6 +41,10 @@ public class JmsSelectorInTest extends CamelTestSupport {
template.sendBodyAndHeader("activemq:queue:foo", "Santa Rita", "drink", "wine");
mock.assertIsSatisfied();
+
+ // and there should also only be 2 if browsing as the selector was configured in the route builder
+ JmsQueueEndpoint endpoint = context.getEndpoint("activemq:queue:foo", JmsQueueEndpoint.class);
+ assertEquals(2, endpoint.getExchanges().size());
}
protected CamelContext createCamelContext() throws Exception {
@@ -58,7 +62,7 @@ public class JmsSelectorInTest extends CamelTestSupport {
JmsEndpoint endpoint = context.getEndpoint("activemq:queue:foo", JmsEndpoint.class);
endpoint.setSelector("drink IN ('beer', 'wine')");
- from(endpoint).to("mock:result");
+ from(endpoint).to("log:drink").to("mock:result");
}
};
}
[3/3] git commit: CAMEL-7649: camel-jms - The QueueBrowseStrategy
need support for JMS Selector.
Posted by da...@apache.org.
CAMEL-7649: camel-jms - The QueueBrowseStrategy need support for JMS Selector.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5a5f6615
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5a5f6615
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5a5f6615
Branch: refs/heads/master
Commit: 5a5f6615598cbcefcb9ecb7ee0c5e3a5b9aa42e2
Parents: 759a4d6
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Aug 12 10:37:34 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 12 10:39:11 2014 +0200
----------------------------------------------------------------------
.../jms/DefaultQueueBrowseStrategy.java | 76 ++++++++++----------
.../camel/component/jms/JmsQueueEndpoint.java | 6 +-
.../component/jms/QueueBrowseStrategy.java | 2 -
3 files changed, 39 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/5a5f6615/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
index f5cb164..3258d61 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java
@@ -37,47 +37,47 @@ import org.springframework.jms.core.JmsOperations;
public class DefaultQueueBrowseStrategy implements QueueBrowseStrategy {
public List<Exchange> browse(JmsOperations template, String queue, final JmsQueueEndpoint endpoint) {
- return template.browse(queue, new BrowserCallback<List<Exchange>>() {
- public List<Exchange> doInJms(Session session, QueueBrowser browser) throws JMSException {
- int size = endpoint.getMaximumBrowseSize();
- if (size <= 0) {
- size = Integer.MAX_VALUE;
- }
+ if (endpoint.getSelector() != null) {
+ return template.browseSelected(queue, endpoint.getSelector(), new BrowserCallback<List<Exchange>>() {
+ public List<Exchange> doInJms(Session session, QueueBrowser browser) throws JMSException {
+ int size = endpoint.getMaximumBrowseSize();
+ if (size <= 0) {
+ size = Integer.MAX_VALUE;
+ }
- // not the best implementation in the world as we have to browse
- // the entire queue, which could be massive
- List<Exchange> answer = new ArrayList<Exchange>();
- Enumeration<?> iter = browser.getEnumeration();
- for (int i = 0; i < size && iter.hasMoreElements(); i++) {
- Message message = (Message) iter.nextElement();
- Exchange exchange = endpoint.createExchange(message);
- answer.add(exchange);
+ // not the best implementation in the world as we have to browse
+ // the entire queue, which could be massive
+ List<Exchange> answer = new ArrayList<Exchange>();
+ Enumeration<?> iter = browser.getEnumeration();
+ for (int i = 0; i < size && iter.hasMoreElements(); i++) {
+ Message message = (Message) iter.nextElement();
+ Exchange exchange = endpoint.createExchange(message);
+ answer.add(exchange);
+ }
+ return answer;
}
- return answer;
- }
- });
- }
+ });
+ } else {
+ return template.browse(queue, new BrowserCallback<List<Exchange>>() {
+ public List<Exchange> doInJms(Session session, QueueBrowser browser) throws JMSException {
+ int size = endpoint.getMaximumBrowseSize();
+ if (size <= 0) {
+ size = Integer.MAX_VALUE;
+ }
- @Override
- public List<Exchange> browseSelected(final String selector, final JmsOperations template, final String queue, final JmsQueueEndpoint endpoint) {
- return template.browseSelected(queue, selector, new BrowserCallback<List<Exchange>>() {
- public List<Exchange> doInJms(Session session, QueueBrowser browser) throws JMSException {
- int size = endpoint.getMaximumBrowseSize();
- if (size <= 0) {
- size = Integer.MAX_VALUE;
+ // not the best implementation in the world as we have to browse
+ // the entire queue, which could be massive
+ List<Exchange> answer = new ArrayList<Exchange>();
+ Enumeration<?> iter = browser.getEnumeration();
+ for (int i = 0; i < size && iter.hasMoreElements(); i++) {
+ Message message = (Message) iter.nextElement();
+ Exchange exchange = endpoint.createExchange(message);
+ answer.add(exchange);
+ }
+ return answer;
}
-
- // not the best implementation in the world as we have to browse
- // the entire queue, which could be massive
- List<Exchange> answer = new ArrayList<Exchange>();
- Enumeration<?> iter = browser.getEnumeration();
- for (int i = 0; i < size && iter.hasMoreElements(); i++) {
- Message message = (Message) iter.nextElement();
- Exchange exchange = endpoint.createExchange(message);
- answer.add(exchange);
- }
- return answer;
- }
- });
+ });
+ }
}
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/5a5f6615/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
index e71c577..cafc1c1 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
@@ -95,11 +95,7 @@ public class JmsQueueEndpoint extends JmsEndpoint implements BrowsableEndpoint {
}
String queue = getDestinationName();
JmsOperations template = getConfiguration().createInOnlyTemplate(this, false, queue);
- if (getSelector() != null) {
- return queueBrowseStrategy.browseSelected(getSelector(), template, queue, this);
- } else {
- return queueBrowseStrategy.browse(template, queue, this);
- }
+ return queueBrowseStrategy.browse(template, queue, this);
}
@ManagedOperation(description = "Current number of Exchanges in Queue")
http://git-wip-us.apache.org/repos/asf/camel/blob/5a5f6615/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
index 44727a2..d973206 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java
@@ -28,6 +28,4 @@ public interface QueueBrowseStrategy {
List<Exchange> browse(JmsOperations template, String queue, JmsQueueEndpoint endpoint);
- List<Exchange> browseSelected(String selector, JmsOperations template, String queue, JmsQueueEndpoint endpoint);
-
}