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 2019/12/10 10:09:27 UTC

[camel] branch master updated: CAMEL-14282: came-nsq - Configure servers on component level

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

davsclaus 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 8482457  CAMEL-14282: came-nsq - Configure servers on component level
8482457 is described below

commit 84824570068479f9a5898567bcf9aeaa07c6b4fd
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Dec 10 10:52:58 2019 +0100

    CAMEL-14282: came-nsq - Configure servers on component level
---
 .../camel-nsq/src/main/docs/nsq-component.adoc     | 50 +++++++++++++++++++---
 .../apache/camel/component/nsq/NsqComponent.java   | 26 +++++++++--
 .../camel/component/nsq/NsqConfiguration.java      | 23 ++--------
 .../apache/camel/component/nsq/NsqEndpoint.java    | 10 ++++-
 .../apache/camel/component/nsq/NsqProducer.java    |  2 -
 .../camel/component/nsq/NsqConsumerTest.java       |  2 +-
 .../camel/component/nsq/NsqProducerTest.java       |  5 ++-
 .../apache/camel/component/nsq/NsqTestSupport.java |  4 +-
 .../endpoint/dsl/NsqEndpointBuilderFactory.java    | 31 +++++++-------
 .../modules/ROOT/pages/nsq-component.adoc          | 50 +++++++++++++++++++---
 .../nsq/springboot/NsqComponentConfiguration.java  | 13 ++++++
 11 files changed, 155 insertions(+), 61 deletions(-)

diff --git a/components/camel-nsq/src/main/docs/nsq-component.adoc b/components/camel-nsq/src/main/docs/nsq-component.adoc
index b22aace..b0060d1 100644
--- a/components/camel-nsq/src/main/docs/nsq-component.adoc
+++ b/components/camel-nsq/src/main/docs/nsq-component.adoc
@@ -26,22 +26,23 @@ their `pom.xml` for this component.
 
 [source,java]
 ----------------------
-nsq:servers[?options]
+nsq:topic[?options]
 ----------------------
 
-Where *servers* represents the list of NSQ servers - nsqlookupd servers in the case of a consumer and nsqd servers in the case of a producer.
+Where *topic* is the topic name
 
 == Options
 
 
 // component options: START
-The NSQ component supports 4 options, which are listed below.
+The NSQ component supports 5 options, which are listed below.
 
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
+| *servers* (common) | The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer). |  | String
 | *useGlobalSslContext Parameters* (security) | Enable usage of global SSL context parameters. | false | boolean
 | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
@@ -57,7 +58,7 @@ The NSQ component supports 4 options, which are listed below.
 The NSQ endpoint is configured using URI syntax:
 
 ----
-nsq:servers
+nsq:topic
 ----
 
 with the following path and query parameters:
@@ -68,7 +69,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *servers* | *Required* The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer). |  | String
+| *topic* | *Required* The name of topic we want to use |  | String
 |===
 
 
@@ -78,7 +79,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *topic* (common) | *Required* The name of topic we want to use |  | String
+| *servers* (common) | The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer). |  | String
 | *userAgent* (common) | A String to identify the kind of client |  | String
 | *autoFinish* (consumer) | Automatically finish the NSQ message when it is retrieved from the quese and before the Exchange is processed. | true | Boolean
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
@@ -114,7 +115,7 @@ When using Spring Boot make sure to use the following Maven dependency to have s
 ----
 
 
-The component supports 5 options, which are listed below.
+The component supports 6 options, which are listed below.
 
 
 
@@ -125,6 +126,41 @@ The component supports 5 options, which are listed below.
 | *camel.component.nsq.bridge-error-handler* | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | Boolean
 | *camel.component.nsq.enabled* | Whether to enable auto configuration of the nsq component. This is enabled by default. |  | Boolean
 | *camel.component.nsq.lazy-start-producer* | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then c [...]
+| *camel.component.nsq.servers* | The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer). |  | String
 | *camel.component.nsq.use-global-ssl-context-parameters* | Enable usage of global SSL context parameters. | false | Boolean
 |===
 // spring-boot-auto-configure options: END
+
+== Examples
+
+To send a message to a NSQ server
+
+[source,java]
+----
+from("direct:start").to("nsq:myTopic?servers=myserver:4161");
+----
+
+And to receive messages from NSQ
+
+[source,xml]
+----
+<route>
+  <from uri="nsq:myTopic?servers=myserver:4161"/>
+  <to uri="bean:doSomething"/>
+</route>
+----
+
+The server can be configured on the component level, for example if using Spring Boot in the `application.properties` file:
+
+[source,properties]
+----
+camel.component.nsq.servers=myserver1:4161,my-second-server:4161
+----
+
+Then you can omit the servers from the endpoint URI
+
+[source,java]
+----
+from("direct:start").to("nsq:myTopic");
+----
+
diff --git a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqComponent.java b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqComponent.java
index 8a8a239..9f9a94c 100644
--- a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqComponent.java
+++ b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqComponent.java
@@ -23,6 +23,7 @@ import org.apache.camel.SSLContextParametersAware;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * Represents the component that manages {@link NsqEndpoint}.
@@ -30,23 +31,42 @@ import org.apache.camel.support.DefaultComponent;
 @Component("nsq")
 public class NsqComponent extends DefaultComponent implements SSLContextParametersAware {
 
+    @Metadata
+    private String servers;
     @Metadata(label = "security", defaultValue = "false")
     private boolean useGlobalSslContextParameters;
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
         NsqConfiguration configuration = new NsqConfiguration();
-        setProperties(configuration, parameters);
-        configuration.setServers(remaining);
+        configuration.setServers(servers);
+        configuration.setTopic(remaining);
+
+        if (ObjectHelper.isEmpty(remaining)) {
+            throw new IllegalArgumentException("Topic must be configured");
+        }
+
+        NsqEndpoint endpoint = new NsqEndpoint(uri, this, configuration);
+        setProperties(endpoint, parameters);
 
         if (configuration.getSslContextParameters() == null) {
             configuration.setSslContextParameters(retrieveGlobalSslContextParameters());
         }
 
-        NsqEndpoint endpoint = new NsqEndpoint(uri, this, configuration);
         return endpoint;
     }
 
+    /**
+     * The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer).
+     */
+    public String getServers() {
+        return servers;
+    }
+
+    public void setServers(String servers) {
+        this.servers = servers;
+    }
+
     @Override
     public boolean isUseGlobalSslContextParameters() {
         return this.useGlobalSslContextParameters;
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 f63379c..c9e1e92 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
@@ -32,12 +32,11 @@ import static org.apache.camel.component.nsq.NsqConstants.NSQ_DEFAULT_PORT;
 @UriParams
 public class NsqConfiguration {
 
-    @UriPath(description = "The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer).")
-    @Metadata(required = true)
-    private String servers;
-    @UriParam(description = "The NSQ topic")
+    @UriPath(description = "The NSQ topic")
     @Metadata(required = true)
     private String topic;
+    @UriParam(description = "The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer).")
+    private String servers;
     @UriParam(label = "consumer", description = "The NSQ channel")
     private String channel;
     @UriParam(label = "consumer", defaultValue = "10")
@@ -61,9 +60,6 @@ public class NsqConfiguration {
     @UriParam(label = "security")
     private SSLContextParameters sslContextParameters;
 
-    /*
-     * URL a NSQ lookup server hostname.
-     */
     public String getServers() {
         return servers;
     }
@@ -226,17 +222,4 @@ public class NsqConfiguration {
         this.sslContextParameters = sslContextParameters;
     }
 
-    private String splitServers() {
-        StringBuilder servers = new StringBuilder();
-
-        String[] pieces = getServers().split(",");
-        for (int i = 0; i < pieces.length; i++) {
-            if (i < pieces.length - 1) {
-                servers.append(pieces[i] + ",");
-            } else {
-                servers.append(pieces[i]);
-            }
-        }
-        return servers.toString();
-    }
 }
diff --git a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqEndpoint.java b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqEndpoint.java
index 509ecd6..829b191 100644
--- a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqEndpoint.java
+++ b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqEndpoint.java
@@ -35,7 +35,7 @@ import org.apache.camel.util.ObjectHelper;
 /**
  * Represents a nsq endpoint.
  */
-@UriEndpoint(firstVersion = "2.23.0", scheme = "nsq", title = "NSQ", syntax = "nsq:servers", label = "messaging")
+@UriEndpoint(firstVersion = "2.23.0", scheme = "nsq", title = "NSQ", syntax = "nsq:topic", label = "messaging")
 public class NsqEndpoint extends DefaultEndpoint {
 
     @UriParam
@@ -56,13 +56,19 @@ public class NsqEndpoint extends DefaultEndpoint {
         if (ObjectHelper.isEmpty(configuration.getTopic())) {
             throw new RuntimeCamelException("Missing required endpoint configuration: topic must be defined for NSQ consumer");
         }
-        return new NsqConsumer(this, processor);
+        Consumer consumer = new NsqConsumer(this, processor);
+        configureConsumer(consumer);
+        return consumer;
     }
 
     public ExecutorService createExecutor() {
         return getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, "NsqTopic[" + configuration.getTopic() + "]", configuration.getPoolSize());
     }
 
+    public void setConfiguration(NsqConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
     public NsqConfiguration getConfiguration() {
         return configuration;
     }
diff --git a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqProducer.java b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqProducer.java
index 7cb9018..d099f7c 100644
--- a/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqProducer.java
+++ b/components/camel-nsq/src/main/java/org/apache/camel/component/nsq/NsqProducer.java
@@ -45,11 +45,9 @@ public class NsqProducer extends DefaultProducer {
 
     @Override
     public void process(Exchange exchange) throws Exception {
-
         String topic = exchange.getIn().getHeader(NsqConstants.NSQ_MESSAGE_TOPIC, configuration.getTopic(), String.class);
 
         LOG.debug("Publishing to topic: {}", topic);
-
         byte[] body = exchange.getIn().getBody(byte[].class);
         producer.produce(topic, body);
     }
diff --git a/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqConsumerTest.java b/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqConsumerTest.java
index 7712810..2c20e87 100644
--- a/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqConsumerTest.java
+++ b/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqConsumerTest.java
@@ -86,7 +86,7 @@ public class NsqConsumerTest extends NsqTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                fromF("nsq://%s?topic=%s&lookupInterval=2s&autoFinish=false&requeueInterval=1s", getNsqConsumerUrl(), TOPIC).process(new Processor() {
+                fromF("nsq://%s?servers=%s&lookupInterval=2s&autoFinish=false&requeueInterval=1s", TOPIC, getNsqConsumerUrl()).process(new Processor() {
                     @Override
                     public void process(Exchange exchange) throws Exception {
                         String messageText = exchange.getIn().getBody(String.class);
diff --git a/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqProducerTest.java b/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqProducerTest.java
index 810b835..db42bcf 100644
--- a/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqProducerTest.java
+++ b/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqProducerTest.java
@@ -88,7 +88,10 @@ public class NsqProducerTest extends NsqTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:send").to("nsq://" + getNsqProducerUrl() + "?topic=test");
+                NsqComponent nsq = context.getComponent("nsq", NsqComponent.class);
+                nsq.setServers(getNsqProducerUrl());
+
+                from("direct:send").to("nsq://test");
             }
         };
     }
diff --git a/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqTestSupport.java b/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqTestSupport.java
index 099f6e4..a62747d 100644
--- a/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqTestSupport.java
+++ b/components/camel-nsq/src/test/java/org/apache/camel/component/nsq/NsqTestSupport.java
@@ -28,10 +28,10 @@ import org.testcontainers.containers.Network;
 
 public class NsqTestSupport extends ContainerAwareTestSupport {
 
-    public static final String CONTAINER_NSQLOOKUPD_IMAGE = "nsqio/nsq:v1.1.0";
+    public static final String CONTAINER_NSQLOOKUPD_IMAGE = "nsqio/nsq:v1.2.0";
     public static final String CONTAINER_NSQLOOKUPD_NAME = "nsqlookupd";
 
-    public static final String CONTAINER_NSQD_IMAGE = "nsqio/nsq:v1.1.0";
+    public static final String CONTAINER_NSQD_IMAGE = "nsqio/nsq:v1.2.0";
     public static final String CONTAINER_NSQD_NAME = "nsqd";
 
     Network network;
diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/NsqEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/NsqEndpointBuilderFactory.java
index 97d5752..0ec0a32 100644
--- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/NsqEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/NsqEndpointBuilderFactory.java
@@ -42,15 +42,15 @@ public interface NsqEndpointBuilderFactory {
             return (AdvancedNsqEndpointConsumerBuilder) this;
         }
         /**
-         * The name of topic we want to use.
+         * The hostnames of one or more nsqlookupd servers (consumer) or nsqd
+         * servers (producer).
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: common
          */
-        default NsqEndpointConsumerBuilder topic(String topic) {
-            doSetProperty("topic", topic);
+        default NsqEndpointConsumerBuilder servers(String servers) {
+            doSetProperty("servers", servers);
             return this;
         }
         /**
@@ -428,15 +428,15 @@ public interface NsqEndpointBuilderFactory {
             return (AdvancedNsqEndpointProducerBuilder) this;
         }
         /**
-         * The name of topic we want to use.
+         * The hostnames of one or more nsqlookupd servers (consumer) or nsqd
+         * servers (producer).
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: common
          */
-        default NsqEndpointProducerBuilder topic(String topic) {
-            doSetProperty("topic", topic);
+        default NsqEndpointProducerBuilder servers(String servers) {
+            doSetProperty("servers", servers);
             return this;
         }
         /**
@@ -635,15 +635,15 @@ public interface NsqEndpointBuilderFactory {
             return (AdvancedNsqEndpointBuilder) this;
         }
         /**
-         * The name of topic we want to use.
+         * The hostnames of one or more nsqlookupd servers (consumer) or nsqd
+         * servers (producer).
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: common
          */
-        default NsqEndpointBuilder topic(String topic) {
-            doSetProperty("topic", topic);
+        default NsqEndpointBuilder servers(String servers) {
+            doSetProperty("servers", servers);
             return this;
         }
         /**
@@ -775,11 +775,10 @@ public interface NsqEndpointBuilderFactory {
      * Since: 2.23
      * Maven coordinates: org.apache.camel:camel-nsq
      * 
-     * Syntax: <code>nsq:servers</code>
+     * Syntax: <code>nsq:topic</code>
      * 
-     * Path parameter: servers (required)
-     * The hostnames of one or more nsqlookupd servers (consumer) or nsqd
-     * servers (producer).
+     * Path parameter: topic (required)
+     * The name of topic we want to use
      */
     default NsqEndpointBuilder nsq(String path) {
         class NsqEndpointBuilderImpl extends AbstractEndpointBuilder implements NsqEndpointBuilder, AdvancedNsqEndpointBuilder {
diff --git a/docs/components/modules/ROOT/pages/nsq-component.adoc b/docs/components/modules/ROOT/pages/nsq-component.adoc
index de1ef80..6073e38 100644
--- a/docs/components/modules/ROOT/pages/nsq-component.adoc
+++ b/docs/components/modules/ROOT/pages/nsq-component.adoc
@@ -27,22 +27,23 @@ their `pom.xml` for this component.
 
 [source,java]
 ----------------------
-nsq:servers[?options]
+nsq:topic[?options]
 ----------------------
 
-Where *servers* represents the list of NSQ servers - nsqlookupd servers in the case of a consumer and nsqd servers in the case of a producer.
+Where *topic* is the topic name
 
 == Options
 
 
 // component options: START
-The NSQ component supports 4 options, which are listed below.
+The NSQ component supports 5 options, which are listed below.
 
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
+| *servers* (common) | The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer). |  | String
 | *useGlobalSslContext Parameters* (security) | Enable usage of global SSL context parameters. | false | boolean
 | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
@@ -58,7 +59,7 @@ The NSQ component supports 4 options, which are listed below.
 The NSQ endpoint is configured using URI syntax:
 
 ----
-nsq:servers
+nsq:topic
 ----
 
 with the following path and query parameters:
@@ -69,7 +70,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *servers* | *Required* The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer). |  | String
+| *topic* | *Required* The name of topic we want to use |  | String
 |===
 
 
@@ -79,7 +80,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *topic* (common) | *Required* The name of topic we want to use |  | String
+| *servers* (common) | The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer). |  | String
 | *userAgent* (common) | A String to identify the kind of client |  | String
 | *autoFinish* (consumer) | Automatically finish the NSQ message when it is retrieved from the quese and before the Exchange is processed. | true | Boolean
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
@@ -115,7 +116,7 @@ When using Spring Boot make sure to use the following Maven dependency to have s
 ----
 
 
-The component supports 5 options, which are listed below.
+The component supports 6 options, which are listed below.
 
 
 
@@ -126,6 +127,41 @@ The component supports 5 options, which are listed below.
 | *camel.component.nsq.bridge-error-handler* | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | Boolean
 | *camel.component.nsq.enabled* | Whether to enable auto configuration of the nsq component. This is enabled by default. |  | Boolean
 | *camel.component.nsq.lazy-start-producer* | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then c [...]
+| *camel.component.nsq.servers* | The hostnames of one or more nsqlookupd servers (consumer) or nsqd servers (producer). |  | String
 | *camel.component.nsq.use-global-ssl-context-parameters* | Enable usage of global SSL context parameters. | false | Boolean
 |===
 // spring-boot-auto-configure options: END
+
+== Examples
+
+To send a message to a NSQ server
+
+[source,java]
+----
+from("direct:start").to("nsq:myTopic?servers=myserver:4161");
+----
+
+And to receive messages from NSQ
+
+[source,xml]
+----
+<route>
+  <from uri="nsq:myTopic?servers=myserver:4161"/>
+  <to uri="bean:doSomething"/>
+</route>
+----
+
+The server can be configured on the component level, for example if using Spring Boot in the `application.properties` file:
+
+[source,properties]
+----
+camel.component.nsq.servers=myserver1:4161,my-second-server:4161
+----
+
+Then you can omit the servers from the endpoint URI
+
+[source,java]
+----
+from("direct:start").to("nsq:myTopic");
+----
+
diff --git a/platforms/spring-boot/components-starter/camel-nsq-starter/src/main/java/org/apache/camel/component/nsq/springboot/NsqComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-nsq-starter/src/main/java/org/apache/camel/component/nsq/springboot/NsqComponentConfiguration.java
index d6b14f3..f78bdc9 100644
--- a/platforms/spring-boot/components-starter/camel-nsq-starter/src/main/java/org/apache/camel/component/nsq/springboot/NsqComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-nsq-starter/src/main/java/org/apache/camel/component/nsq/springboot/NsqComponentConfiguration.java
@@ -37,6 +37,11 @@ public class NsqComponentConfiguration
      */
     private Boolean enabled;
     /**
+     * The hostnames of one or more nsqlookupd servers (consumer) or nsqd
+     * servers (producer).
+     */
+    private String servers;
+    /**
      * Enable usage of global SSL context parameters.
      */
     private Boolean useGlobalSslContextParameters = false;
@@ -66,6 +71,14 @@ public class NsqComponentConfiguration
      */
     private Boolean bridgeErrorHandler = false;
 
+    public String getServers() {
+        return servers;
+    }
+
+    public void setServers(String servers) {
+        this.servers = servers;
+    }
+
     public Boolean getUseGlobalSslContextParameters() {
         return useGlobalSslContextParameters;
     }