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 56947b3 Fixed camel-nats test and added verbose option to component level 56947b3 is described below commit 56947b3ecac52817e4cf74cd5baa98d3553012b6 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sun Mar 29 15:32:14 2020 +0200 Fixed camel-nats test and added verbose option to component level --- .../camel/component/nats/NatsComponentConfigurer.java | 3 +++ .../resources/org/apache/camel/component/nats/nats.json | 3 ++- components/camel-nats/src/main/docs/nats-component.adoc | 5 +++-- .../java/org/apache/camel/component/nats/NatsComponent.java | 13 +++++++++++++ .../org/apache/camel/component/nats/NatsConfiguration.java | 2 +- .../camel/component/nats/NatsConsumerReplyToTest.java | 13 +++++++++---- .../builder/component/dsl/NatsComponentBuilderFactory.java | 13 +++++++++++++ .../builder/endpoint/dsl/NatsEndpointBuilderFactory.java | 12 ++++++------ 8 files changed, 50 insertions(+), 14 deletions(-) diff --git a/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsComponentConfigurer.java b/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsComponentConfigurer.java index 02c239c..ede3088 100644 --- a/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsComponentConfigurer.java +++ b/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsComponentConfigurer.java @@ -28,6 +28,7 @@ public class NatsComponentConfigurer extends PropertyConfigurerSupport implement case "servers": target.setServers(property(camelContext, java.lang.String.class, value)); return true; case "useglobalsslcontextparameters": case "useGlobalSslContextParameters": target.setUseGlobalSslContextParameters(property(camelContext, boolean.class, value)); return true; + case "verbose": target.setVerbose(property(camelContext, boolean.class, value)); return true; default: return false; } } @@ -40,6 +41,7 @@ public class NatsComponentConfigurer extends PropertyConfigurerSupport implement answer.put("lazyStartProducer", boolean.class); answer.put("servers", java.lang.String.class); answer.put("useGlobalSslContextParameters", boolean.class); + answer.put("verbose", boolean.class); return answer; } @@ -56,6 +58,7 @@ public class NatsComponentConfigurer extends PropertyConfigurerSupport implement case "servers": return target.getServers(); case "useglobalsslcontextparameters": case "useGlobalSslContextParameters": return target.isUseGlobalSslContextParameters(); + case "verbose": return target.isVerbose(); default: return null; } } diff --git a/components/camel-nats/src/generated/resources/org/apache/camel/component/nats/nats.json b/components/camel-nats/src/generated/resources/org/apache/camel/component/nats/nats.json index deb76bf..5130eb7 100644 --- a/components/camel-nats/src/generated/resources/org/apache/camel/component/nats/nats.json +++ b/components/camel-nats/src/generated/resources/org/apache/camel/component/nats/nats.json @@ -20,6 +20,7 @@ }, "componentProperties": { "servers": { "kind": "property", "displayName": "Servers", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "URLs to one or more NAT servers. Use comma to separate URLs when specifying multiple servers." }, + "verbose": { "kind": "property", "displayName": "Verbose", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether or not running in verbose mode" }, "bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "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 [...] "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "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 r [...] "basicPropertyBinding": { "kind": "property", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" }, @@ -34,7 +35,7 @@ "maxReconnectAttempts": { "kind": "parameter", "displayName": "Max Reconnect Attempts", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "secret": false, "defaultValue": "60", "configurationClass": "org.apache.camel.component.nats.NatsConfiguration", "configurationField": "configuration", "description": "Max reconnection attempts" }, "noEcho": { "kind": "parameter", "displayName": "No Echo", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.nats.NatsConfiguration", "configurationField": "configuration", "description": "Turn off echo. If supported by the gnatsd version you are connecting to this flag will prevent the server from echoing messages back to the conne [...] "noRandomizeServers": { "kind": "parameter", "displayName": "No Randomize Servers", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.nats.NatsConfiguration", "configurationField": "configuration", "description": "Whether or not randomizing the order of servers for the connection attempts" }, - "pedantic": { "kind": "parameter", "displayName": "Pedantic", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.nats.NatsConfiguration", "configurationField": "configuration", "description": "Whether or not running in pedantic mode (this affects performace)" }, + "pedantic": { "kind": "parameter", "displayName": "Pedantic", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.nats.NatsConfiguration", "configurationField": "configuration", "description": "Whether or not running in pedantic mode (this affects performance)" }, "pingInterval": { "kind": "parameter", "displayName": "Ping Interval", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "secret": false, "defaultValue": "120000", "configurationClass": "org.apache.camel.component.nats.NatsConfiguration", "configurationField": "configuration", "description": "Ping interval to be aware if connection is still alive (in milliseconds)" }, "reconnect": { "kind": "parameter", "displayName": "Reconnect", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "true", "configurationClass": "org.apache.camel.component.nats.NatsConfiguration", "configurationField": "configuration", "description": "Whether or not using reconnection feature" }, "reconnectTimeWait": { "kind": "parameter", "displayName": "Reconnect Time Wait", "group": "common", "label": "common", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "secret": false, "defaultValue": "2000", "configurationClass": "org.apache.camel.component.nats.NatsConfiguration", "configurationField": "configuration", "description": "Waiting time before attempts reconnection (in milliseconds)" }, diff --git a/components/camel-nats/src/main/docs/nats-component.adoc b/components/camel-nats/src/main/docs/nats-component.adoc index 16f18c5..61524a2 100644 --- a/components/camel-nats/src/main/docs/nats-component.adoc +++ b/components/camel-nats/src/main/docs/nats-component.adoc @@ -35,7 +35,7 @@ Where *topic* is the topic name // component options: START -The Nats component supports 5 options, which are listed below. +The Nats component supports 6 options, which are listed below. @@ -43,6 +43,7 @@ The Nats component supports 5 options, which are listed below. |=== | Name | Description | Default | Type | *servers* (common) | URLs to one or more NAT servers. Use comma to separate URLs when specifying multiple servers. | | String +| *verbose* (common) | Whether or not running in verbose mode | false | 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 | *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 [...] | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean @@ -86,7 +87,7 @@ with the following path and query parameters: | *maxReconnectAttempts* (common) | Max reconnection attempts | 60 | int | *noEcho* (common) | Turn off echo. If supported by the gnatsd version you are connecting to this flag will prevent the server from echoing messages back to the connection if it has subscriptions on the subject being published to. | false | boolean | *noRandomizeServers* (common) | Whether or not randomizing the order of servers for the connection attempts | false | boolean -| *pedantic* (common) | Whether or not running in pedantic mode (this affects performace) | false | boolean +| *pedantic* (common) | Whether or not running in pedantic mode (this affects performance) | false | boolean | *pingInterval* (common) | Ping interval to be aware if connection is still alive (in milliseconds) | 120000 | int | *reconnect* (common) | Whether or not using reconnection feature | true | boolean | *reconnectTimeWait* (common) | Waiting time before attempts reconnection (in milliseconds) | 2000 | int diff --git a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsComponent.java b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsComponent.java index fc18780..0d2b8d9 100644 --- a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsComponent.java +++ b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsComponent.java @@ -31,12 +31,15 @@ public class NatsComponent extends DefaultComponent implements SSLContextParamet private String servers; @Metadata(label = "security", defaultValue = "false") private boolean useGlobalSslContextParameters; + @Metadata + private boolean verbose; @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { NatsConfiguration config = new NatsConfiguration(); config.setTopic(remaining); config.setServers(servers); + config.setVerbose(verbose); if (config.getSslContextParameters() == null) { config.setSslContextParameters(retrieveGlobalSslContextParameters()); @@ -72,4 +75,14 @@ public class NatsComponent extends DefaultComponent implements SSLContextParamet this.useGlobalSslContextParameters = useGlobalSslContextParameters; } + public boolean isVerbose() { + return verbose; + } + + /** + * Whether or not running in verbose mode + */ + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } } diff --git a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java index 0717e52..f4da01c 100644 --- a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java +++ b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java @@ -126,7 +126,7 @@ public class NatsConfiguration { } /** - * Whether or not running in pedantic mode (this affects performace) + * Whether or not running in pedantic mode (this affects performance) */ public boolean isPedantic() { return pedantic; diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerReplyToTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerReplyToTest.java index 5572854..1fe4ca0 100644 --- a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerReplyToTest.java +++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerReplyToTest.java @@ -26,18 +26,20 @@ public class NatsConsumerReplyToTest extends NatsTestSupport { @EndpointInject("mock:result") protected MockEndpoint mockResultEndpoint; + @EndpointInject("mock:reply") + protected MockEndpoint mockReplyEndpoint; + @Test public void testReplyTo() throws Exception { mockResultEndpoint.expectedBodiesReceived("World"); mockResultEndpoint.expectedHeaderReceived(NatsConstants.NATS_SUBJECT, "test"); + mockReplyEndpoint.expectedBodiesReceived("Bye World"); + mockReplyEndpoint.expectedHeaderReceived(NatsConstants.NATS_SUBJECT, "myReplyQueue"); template.sendBody("direct:send", "World"); mockResultEndpoint.assertIsSatisfied(); - - // grab reply message from the reply queue - String out = consumer.receiveBody("nats:myReplyQueue", 5000, String.class); - assertEquals("Bye World", out); + mockReplyEndpoint.assertIsSatisfied(); } @Override @@ -52,6 +54,9 @@ public class NatsConsumerReplyToTest extends NatsTestSupport { .to(mockResultEndpoint) .convertBodyTo(String.class) .setBody().simple("Bye ${body}"); + + from("nats:myReplyQueue") + .to("mock:reply"); } }; } diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/NatsComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/NatsComponentBuilderFactory.java index 64ff3fe..cde9e71 100644 --- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/NatsComponentBuilderFactory.java +++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/NatsComponentBuilderFactory.java @@ -59,6 +59,18 @@ public interface NatsComponentBuilderFactory { return this; } /** + * Whether or not running in verbose mode. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: common + */ + default NatsComponentBuilder verbose(boolean verbose) { + doSetProperty("verbose", verbose); + return this; + } + /** * 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 @@ -142,6 +154,7 @@ public interface NatsComponentBuilderFactory { Object value) { switch (name) { case "servers": ((NatsComponent) component).setServers((java.lang.String) value); return true; + case "verbose": ((NatsComponent) component).setVerbose((boolean) value); return true; case "bridgeErrorHandler": ((NatsComponent) component).setBridgeErrorHandler((boolean) value); return true; case "lazyStartProducer": ((NatsComponent) component).setLazyStartProducer((boolean) value); return true; case "basicPropertyBinding": ((NatsComponent) component).setBasicPropertyBinding((boolean) value); return true; diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NatsEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NatsEndpointBuilderFactory.java index 04e0b41..b65b39e 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NatsEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NatsEndpointBuilderFactory.java @@ -228,7 +228,7 @@ public interface NatsEndpointBuilderFactory { return this; } /** - * Whether or not running in pedantic mode (this affects performace). + * Whether or not running in pedantic mode (this affects performance). * * The option is a: <code>boolean</code> type. * @@ -240,7 +240,7 @@ public interface NatsEndpointBuilderFactory { return this; } /** - * Whether or not running in pedantic mode (this affects performace). + * Whether or not running in pedantic mode (this affects performance). * * The option will be converted to a <code>boolean</code> type. * @@ -895,7 +895,7 @@ public interface NatsEndpointBuilderFactory { return this; } /** - * Whether or not running in pedantic mode (this affects performace). + * Whether or not running in pedantic mode (this affects performance). * * The option is a: <code>boolean</code> type. * @@ -907,7 +907,7 @@ public interface NatsEndpointBuilderFactory { return this; } /** - * Whether or not running in pedantic mode (this affects performace). + * Whether or not running in pedantic mode (this affects performance). * * The option will be converted to a <code>boolean</code> type. * @@ -1443,7 +1443,7 @@ public interface NatsEndpointBuilderFactory { return this; } /** - * Whether or not running in pedantic mode (this affects performace). + * Whether or not running in pedantic mode (this affects performance). * * The option is a: <code>boolean</code> type. * @@ -1455,7 +1455,7 @@ public interface NatsEndpointBuilderFactory { return this; } /** - * Whether or not running in pedantic mode (this affects performace). + * Whether or not running in pedantic mode (this affects performance). * * The option will be converted to a <code>boolean</code> type. *