You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/09/08 17:53:07 UTC
[camel] 01/04: CAMEL-15508 - Camel-NSQ: Support custom NSQLookup
implementation
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit db21bfdb0d0bd19717ec4d775b72ce0c57d2aa8f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Sep 8 18:01:34 2020 +0200
CAMEL-15508 - Camel-NSQ: Support custom NSQLookup implementation
---
.../org/apache/camel/component/nsq/NsqConfiguration.java | 14 ++++++++++++++
.../java/org/apache/camel/component/nsq/NsqConsumer.java | 9 ++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqConfiguration.java b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqConfiguration.java
index 584f4fa..24c6cf7 100644
--- a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqConfiguration.java
+++ b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.nsq;
import java.util.Set;
import com.github.brainlag.nsq.ServerAddress;
+import com.github.brainlag.nsq.lookup.NSQLookup;
import com.google.common.collect.Sets;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriParam;
@@ -56,6 +57,8 @@ public class NsqConfiguration {
@UriParam(label = "consumer", defaultValue = "-1", javaType = "java.time.Duration",
description = "The NSQ consumer timeout period for messages retrieved from the queue. A value of -1 is the server default")
private long messageTimeout = -1;
+ @UriParam(label = "consumer", description = "A Custom NSQ lookup implementation")
+ private NSQLookup customNSQLookup;
@UriParam(description = "A String to identify the kind of client")
private String userAgent;
@UriParam(label = "security")
@@ -225,4 +228,15 @@ public class NsqConfiguration {
this.sslContextParameters = sslContextParameters;
}
+ public NSQLookup getCustomNSQLookup() {
+ return customNSQLookup;
+ }
+
+ /**
+ * Set a custom NSQLookup implementation
+ */
+ public void setCustomNSQLookup(NSQLookup customNSQLookup) {
+ this.customNSQLookup = customNSQLookup;
+ }
+
}
diff --git a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqConsumer.java b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqConsumer.java
index 3792863..7fb4979 100644
--- a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqConsumer.java
+++ b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqConsumer.java
@@ -29,6 +29,7 @@ import org.apache.camel.ExchangePattern;
import org.apache.camel.ExtendedExchange;
import org.apache.camel.Processor;
import org.apache.camel.support.DefaultConsumer;
+import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,9 +63,15 @@ public class NsqConsumer extends DefaultConsumer {
super.doStart();
LOG.debug("Starting NSQ Consumer");
executor = getEndpoint().createExecutor();
+
+ NSQLookup lookup;
LOG.debug("Getting NSQ Connection");
- NSQLookup lookup = new DefaultNSQLookup();
+ if (ObjectHelper.isEmpty(configuration.getCustomNSQLookup())) {
+ lookup = new DefaultNSQLookup();
+ } else {
+ lookup = configuration.getCustomNSQLookup();
+ }
for (ServerAddress server : configuration.getServerAddresses()) {
lookup.addLookupAddress(server.getHost(),