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 d0082cb  CAMEL-16094 camel-milo: connection caching.
d0082cb is described below

commit d0082cb8c1f60d5e9bb7128fc85bb6e963398cb5
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue Feb 9 07:25:13 2021 +0100

    CAMEL-16094 camel-milo: connection caching.
---
 .../camel/catalog/components/milo-client.json      |  1 +
 .../camel/catalog/docs/milo-client-component.adoc  |  2 +-
 .../milo/client/MiloClientComponentConfigurer.java | 17 +++++++----
 .../camel/component/milo/client/milo-client.json   |  2 +-
 .../src/main/docs/milo-client-component.adoc       |  2 +-
 .../client/MiloClientCachingConnectionManager.java | 35 +++++++++++++++++-----
 .../component/milo/client/MiloClientComponent.java | 17 +++++------
 .../milo/client/MiloClientConnection.java          |  6 +---
 .../milo/client/MiloClientConnectionManager.java   | 26 ++++++++++++++++
 .../component/milo/client/MiloClientEndpoint.java  |  4 +--
 .../MiloClientCachingConnectionManagerTest.java    | 24 ++++++++++++---
 .../dsl/MiloClientComponentBuilderFactory.java     | 34 ++++++++++-----------
 .../modules/ROOT/pages/milo-client-component.adoc  |  2 +-
 13 files changed, 117 insertions(+), 55 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/milo-client.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/milo-client.json
index 5f31b8e..9435296 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/milo-client.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/milo-client.json
@@ -40,6 +40,7 @@
     "keyStoreUrl": { "kind": "property", "displayName": "Key Store Url", 
"group": "client", "label": "client", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The URL where the key 
should be loaded from" },
     "maxPendingPublishRequests": { "kind": "property", "displayName": "Max 
Pending Publish Requests", "group": "client", "label": "client", "required": 
false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The maximum number of 
pending publish requests" },
     "maxResponseMessageSize": { "kind": "property", "displayName": "Max 
Response Message Size", "group": "client", "label": "client", "required": 
false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The maximum number of 
bytes a response message may have" },
+    "miloClientConnectionManager": { "kind": "property", "displayName": "Milo 
Client Connection Manager", "group": "client", "label": "client", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.component.milo.client.MiloClientConnectionManager", 
"deprecated": false, "autowired": true, "secret": false, "description": 
"Instance for managing client connections" },
     "overrideHost": { "kind": "property", "displayName": "Override Host", 
"group": "client", "label": "client", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "Override the server 
reported endpoint host with the host from the endpoint URI." },
     "productUri": { "kind": "property", "displayName": "Product Uri", "group": 
"client", "label": "client", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "http:\/\/camel.apache.org\/EclipseMilo", "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The product URI" },
     "requestedPublishingInterval": { "kind": "property", "displayName": 
"Requested Publishing Interval", "group": "client", "label": "client", 
"required": false, "type": "number", "javaType": "java.lang.Double", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 
"1_000.0", "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The requested publishing 
interval in milliseconds" },
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/milo-client-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/milo-client-component.adoc
index e55ed7b..0dc4c25 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/milo-client-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/milo-client-component.adoc
@@ -44,7 +44,6 @@ The OPC UA Client component supports 25 options, which are 
listed below.
 | *configuration* (common) | All default options for client configurations |  
| MiloClientConfiguration
 | *discoveryEndpointSuffix* (common) | A suffix for endpoint URI when 
discovering |  | String
 | *discoveryEndpointUri* (common) | An alternative discovery URI |  | String
-| *miloClientCachingConnection{zwsp}Manager* (common) | Instance for managing 
client connections. |  | MiloClientConnectionManager
 | *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 [...]
 | *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used 
for automatic autowiring options (the option must be marked as autowired) by 
looking up in the registry to find if there is a single instance of matching 
type, which then gets configured on the component. This can be used for 
automatic configuring JDBC data sources, JMS connection factories, AWS Clients, 
etc. | true | boolean
@@ -59,6 +58,7 @@ The OPC UA Client component supports 25 options, which are 
listed below.
 | *keyStoreUrl* (client) | The URL where the key should be loaded from |  | 
String
 | *maxPendingPublishRequests* (client) | The maximum number of pending publish 
requests |  | Long
 | *maxResponseMessageSize* (client) | The maximum number of bytes a response 
message may have |  | Long
+| *miloClientConnectionManager* (client) | *Autowired* Instance for managing 
client connections |  | MiloClientConnectionManager
 | *overrideHost* (client) | Override the server reported endpoint host with 
the host from the endpoint URI. | false | boolean
 | *productUri* (client) | The product URI | 
http://camel.apache.org/EclipseMilo | String
 | *requestedPublishingInterval* (client) | The requested publishing interval 
in milliseconds | 1_000.0 | Double
diff --git 
a/components/camel-milo/src/generated/java/org/apache/camel/component/milo/client/MiloClientComponentConfigurer.java
 
b/components/camel-milo/src/generated/java/org/apache/camel/component/milo/client/MiloClientComponentConfigurer.java
index 1ebe162..1f6b384 100644
--- 
a/components/camel-milo/src/generated/java/org/apache/camel/component/milo/client/MiloClientComponentConfigurer.java
+++ 
b/components/camel-milo/src/generated/java/org/apache/camel/component/milo/client/MiloClientComponentConfigurer.java
@@ -63,8 +63,8 @@ public class MiloClientComponentConfigurer extends 
PropertyConfigurerSupport imp
         case "maxPendingPublishRequests": 
getOrCreateConfiguration(target).setMaxPendingPublishRequests(property(camelContext,
 java.lang.Long.class, value)); return true;
         case "maxresponsemessagesize":
         case "maxResponseMessageSize": 
getOrCreateConfiguration(target).setMaxResponseMessageSize(property(camelContext,
 java.lang.Long.class, value)); return true;
-        case "miloclientcachingconnectionmanager":
-        case "miloClientCachingConnectionManager": 
target.setMiloClientCachingConnectionManager(property(camelContext, 
org.apache.camel.component.milo.client.MiloClientConnectionManager.class, 
value)); return true;
+        case "miloclientconnectionmanager":
+        case "miloClientConnectionManager": 
target.setMiloClientConnectionManager(property(camelContext, 
org.apache.camel.component.milo.client.MiloClientConnectionManager.class, 
value)); return true;
         case "overridehost":
         case "overrideHost": 
getOrCreateConfiguration(target).setOverrideHost(property(camelContext, 
boolean.class, value)); return true;
         case "producturi":
@@ -82,6 +82,11 @@ public class MiloClientComponentConfigurer extends 
PropertyConfigurerSupport imp
     }
 
     @Override
+    public String[] getAutowiredNames() {
+        return new String[]{"miloClientConnectionManager"};
+    }
+
+    @Override
     public Class<?> getOptionType(String name, boolean ignoreCase) {
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "allowedsecuritypolicies":
@@ -119,8 +124,8 @@ public class MiloClientComponentConfigurer extends 
PropertyConfigurerSupport imp
         case "maxPendingPublishRequests": return java.lang.Long.class;
         case "maxresponsemessagesize":
         case "maxResponseMessageSize": return java.lang.Long.class;
-        case "miloclientcachingconnectionmanager":
-        case "miloClientCachingConnectionManager": return 
org.apache.camel.component.milo.client.MiloClientConnectionManager.class;
+        case "miloclientconnectionmanager":
+        case "miloClientConnectionManager": return 
org.apache.camel.component.milo.client.MiloClientConnectionManager.class;
         case "overridehost":
         case "overrideHost": return boolean.class;
         case "producturi":
@@ -176,8 +181,8 @@ public class MiloClientComponentConfigurer extends 
PropertyConfigurerSupport imp
         case "maxPendingPublishRequests": return 
getOrCreateConfiguration(target).getMaxPendingPublishRequests();
         case "maxresponsemessagesize":
         case "maxResponseMessageSize": return 
getOrCreateConfiguration(target).getMaxResponseMessageSize();
-        case "miloclientcachingconnectionmanager":
-        case "miloClientCachingConnectionManager": return 
target.getMiloClientCachingConnectionManager();
+        case "miloclientconnectionmanager":
+        case "miloClientConnectionManager": return 
target.getMiloClientConnectionManager();
         case "overridehost":
         case "overrideHost": return 
getOrCreateConfiguration(target).isOverrideHost();
         case "producturi":
diff --git 
a/components/camel-milo/src/generated/resources/org/apache/camel/component/milo/client/milo-client.json
 
b/components/camel-milo/src/generated/resources/org/apache/camel/component/milo/client/milo-client.json
index ebd3a0f..9435296 100644
--- 
a/components/camel-milo/src/generated/resources/org/apache/camel/component/milo/client/milo-client.json
+++ 
b/components/camel-milo/src/generated/resources/org/apache/camel/component/milo/client/milo-client.json
@@ -26,7 +26,6 @@
     "configuration": { "kind": "property", "displayName": "Configuration", 
"group": "common", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.milo.client.MiloClientConfiguration", 
"deprecated": false, "autowired": false, "secret": false, "description": "All 
default options for client configurations" },
     "discoveryEndpointSuffix": { "kind": "property", "displayName": "Discovery 
Endpoint Suffix", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "A suffix for endpoint 
URI when discovering" },
     "discoveryEndpointUri": { "kind": "property", "displayName": "Discovery 
Endpoint Uri", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "An alternative discovery 
URI" },
-    "miloClientCachingConnectionManager": { "kind": "property", "displayName": 
"Milo Client Caching Connection Manager", "group": "common", "label": "", 
"required": false, "type": "object", "javaType": 
"org.apache.camel.component.milo.client.MiloClientConnectionManager", 
"deprecated": false, "autowired": false, "secret": false, "description": 
"Instance for managing client connections." },
     "bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error 
Handler", "group": "consumer", "label": "consumer", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": 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 me [...]
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start 
Producer", "group": "producer", "label": "producer", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": 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 star [...]
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired 
Enabled", "group": "advanced", "label": "advanced", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether autowiring is 
enabled. This is used for automatic autowiring options (the option must be 
marked as autowired) by looking up in the registry to find if there is a single 
instance of matching type, which t [...]
@@ -41,6 +40,7 @@
     "keyStoreUrl": { "kind": "property", "displayName": "Key Store Url", 
"group": "client", "label": "client", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The URL where the key 
should be loaded from" },
     "maxPendingPublishRequests": { "kind": "property", "displayName": "Max 
Pending Publish Requests", "group": "client", "label": "client", "required": 
false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The maximum number of 
pending publish requests" },
     "maxResponseMessageSize": { "kind": "property", "displayName": "Max 
Response Message Size", "group": "client", "label": "client", "required": 
false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The maximum number of 
bytes a response message may have" },
+    "miloClientConnectionManager": { "kind": "property", "displayName": "Milo 
Client Connection Manager", "group": "client", "label": "client", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.component.milo.client.MiloClientConnectionManager", 
"deprecated": false, "autowired": true, "secret": false, "description": 
"Instance for managing client connections" },
     "overrideHost": { "kind": "property", "displayName": "Override Host", 
"group": "client", "label": "client", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "Override the server 
reported endpoint host with the host from the endpoint URI." },
     "productUri": { "kind": "property", "displayName": "Product Uri", "group": 
"client", "label": "client", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "http:\/\/camel.apache.org\/EclipseMilo", "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The product URI" },
     "requestedPublishingInterval": { "kind": "property", "displayName": 
"Requested Publishing Interval", "group": "client", "label": "client", 
"required": false, "type": "number", "javaType": "java.lang.Double", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 
"1_000.0", "configurationClass": 
"org.apache.camel.component.milo.client.MiloClientConfiguration", 
"configurationField": "configuration", "description": "The requested publishing 
interval in milliseconds" },
diff --git a/components/camel-milo/src/main/docs/milo-client-component.adoc 
b/components/camel-milo/src/main/docs/milo-client-component.adoc
index e55ed7b..0dc4c25 100644
--- a/components/camel-milo/src/main/docs/milo-client-component.adoc
+++ b/components/camel-milo/src/main/docs/milo-client-component.adoc
@@ -44,7 +44,6 @@ The OPC UA Client component supports 25 options, which are 
listed below.
 | *configuration* (common) | All default options for client configurations |  
| MiloClientConfiguration
 | *discoveryEndpointSuffix* (common) | A suffix for endpoint URI when 
discovering |  | String
 | *discoveryEndpointUri* (common) | An alternative discovery URI |  | String
-| *miloClientCachingConnection{zwsp}Manager* (common) | Instance for managing 
client connections. |  | MiloClientConnectionManager
 | *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 [...]
 | *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used 
for automatic autowiring options (the option must be marked as autowired) by 
looking up in the registry to find if there is a single instance of matching 
type, which then gets configured on the component. This can be used for 
automatic configuring JDBC data sources, JMS connection factories, AWS Clients, 
etc. | true | boolean
@@ -59,6 +58,7 @@ The OPC UA Client component supports 25 options, which are 
listed below.
 | *keyStoreUrl* (client) | The URL where the key should be loaded from |  | 
String
 | *maxPendingPublishRequests* (client) | The maximum number of pending publish 
requests |  | Long
 | *maxResponseMessageSize* (client) | The maximum number of bytes a response 
message may have |  | Long
+| *miloClientConnectionManager* (client) | *Autowired* Instance for managing 
client connections |  | MiloClientConnectionManager
 | *overrideHost* (client) | Override the server reported endpoint host with 
the host from the endpoint URI. | false | boolean
 | *productUri* (client) | The product URI | 
http://camel.apache.org/EclipseMilo | String
 | *requestedPublishingInterval* (client) | The requested publishing interval 
in milliseconds | 1_000.0 | Double
diff --git 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientCachingConnectionManager.java
 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientCachingConnectionManager.java
index cd6f47d..c3662a2 100644
--- 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientCachingConnectionManager.java
+++ 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientCachingConnectionManager.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.camel.component.milo.client;
 
 import java.util.HashMap;
@@ -8,25 +24,30 @@ import java.util.Optional;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * A caching {@link MiloClientConnectionManager} which cache and reuses the 
same {@link MiloClientConnection}
+ * for clients with the same cache id ({@link 
MiloClientConfiguration#toCacheId()}.
+ */
 public class MiloClientCachingConnectionManager implements 
MiloClientConnectionManager {
+
     private static final Logger LOG = 
LoggerFactory.getLogger(MiloClientCachingConnectionManager.class);
 
     private final Map<String, ManagedConnection> cache = new HashMap<>();
 
     private static class ManagedConnection {
         private final MiloClientConnection connection;
-        private int amountConsumers = 0;
+        private int consumers;
 
         ManagedConnection(MiloClientConnection connection) {
             this.connection = connection;
         }
 
         void increment() {
-            amountConsumers++;
+            consumers++;
         }
 
         void decrement() {
-            amountConsumers--;
+            consumers--;
         }
     }
 
@@ -36,7 +57,7 @@ public class MiloClientCachingConnectionManager implements 
MiloClientConnectionM
             MonitorFilterConfiguration monitorFilterConfiguration) {
         final String identifier = configuration.toCacheId();
         final ManagedConnection managedConnection
-                = cache.computeIfAbsent(identifier, (k) -> 
managedConnection(configuration, monitorFilterConfiguration));
+                = cache.computeIfAbsent(identifier, k -> 
managedConnection(configuration, monitorFilterConfiguration));
         managedConnection.increment();
         return managedConnection.connection;
     }
@@ -45,14 +66,14 @@ public class MiloClientCachingConnectionManager implements 
MiloClientConnectionM
     public synchronized void releaseConnection(MiloClientConnection 
connection) {
         final Optional<Entry<String, ManagedConnection>> existingConnection = 
this.cache.entrySet().stream()
                 .filter(entry -> 
entry.getValue().connection.equals(connection)).findFirst();
-        existingConnection.ifPresent((entry) -> {
+        existingConnection.ifPresent(entry -> {
             entry.getValue().decrement();
-            if (entry.getValue().amountConsumers <= 0) {
+            if (entry.getValue().consumers <= 0) {
                 try {
                     LOG.debug("Closing connection {}", entry.getKey());
                     entry.getValue().connection.close();
                 } catch (Exception e) {
-                    LOG.warn("Error while closing connection with id {}", 
entry.getKey());
+                    LOG.debug("Error while closing connection with id {}. This 
exception is ignored.", entry.getKey());
                 } finally {
                     cache.remove(entry.getKey());
                 }
diff --git 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java
 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java
index 84a941a..71440d5 100644
--- 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java
+++ 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java
@@ -29,8 +29,8 @@ public class MiloClientComponent extends DefaultComponent {
     @Metadata
     private MiloClientConfiguration configuration = new 
MiloClientConfiguration();
 
-    @Metadata(description = "Instance for managing client connections.")
-    private MiloClientConnectionManager miloClientCachingConnectionManager = 
new MiloClientCachingConnectionManager();
+    @Metadata(autowired = true, label = "client", description = "Instance for 
managing client connections")
+    private MiloClientConnectionManager miloClientConnectionManager = new 
MiloClientCachingConnectionManager();
 
     @Override
     protected Endpoint createEndpoint(final String uri, final String 
remaining, final Map<String, Object> parameters)
@@ -40,7 +40,7 @@ public class MiloClientComponent extends DefaultComponent {
         configuration.setEndpointUri(remaining);
 
         final MiloClientEndpoint endpoint
-                = new MiloClientEndpoint(uri, this, 
configuration.getEndpointUri(), miloClientCachingConnectionManager);
+                = new MiloClientEndpoint(uri, this, 
configuration.getEndpointUri(), miloClientConnectionManager);
         endpoint.setConfiguration(configuration);
         setProperties(endpoint, parameters);
 
@@ -86,14 +86,11 @@ public class MiloClientComponent extends DefaultComponent {
         this.configuration.setRequestTimeout(reconnectTimeout);
     }
 
-    public MiloClientConnectionManager getMiloClientCachingConnectionManager() 
{
-        return miloClientCachingConnectionManager;
+    public MiloClientConnectionManager getMiloClientConnectionManager() {
+        return miloClientConnectionManager;
     }
 
-    /**
-     * @param miloClientCachingConnectionManager - Connection Manager for 
client connections
-     */
-    public void 
setMiloClientCachingConnectionManager(MiloClientConnectionManager 
miloClientCachingConnectionManager) {
-        this.miloClientCachingConnectionManager = 
miloClientCachingConnectionManager;
+    public void setMiloClientConnectionManager(MiloClientConnectionManager 
miloClientConnectionManager) {
+        this.miloClientConnectionManager = miloClientConnectionManager;
     }
 }
diff --git 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
index b282a2d..907992d 100644
--- 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
+++ 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
@@ -34,11 +34,8 @@ import static java.util.Objects.requireNonNull;
 public class MiloClientConnection implements AutoCloseable {
 
     private final MiloClientConfiguration configuration;
-
     private SubscriptionManager manager;
-
-    private boolean initialized;
-
+    private volatile boolean initialized;
     private MonitorFilterConfiguration monitorFilterConfiguration;
 
     public MiloClientConnection(final MiloClientConfiguration configuration,
@@ -128,7 +125,6 @@ public class MiloClientConnection implements AutoCloseable {
      * @return       the outgoing call request
      */
     private Variant[] mapCallValue(final Object value) {
-
         if (value == null) {
             return new Variant[0];
         }
diff --git 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnectionManager.java
 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnectionManager.java
index 7cec949..532312f 100644
--- 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnectionManager.java
+++ 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnectionManager.java
@@ -1,8 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.camel.component.milo.client;
 
+/**
+ * SPI to manage connections.
+ */
 public interface MiloClientConnectionManager {
+
+    /**
+     * Creates the connection
+     */
     MiloClientConnection createConnection(
             MiloClientConfiguration configuration, MonitorFilterConfiguration 
monitorFilterConfiguration);
 
+    /**
+     * Releases the connection
+     */
     void releaseConnection(MiloClientConnection connection);
 }
diff --git 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientEndpoint.java
 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientEndpoint.java
index a1a58ad..286a451 100644
--- 
a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientEndpoint.java
+++ 
b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientEndpoint.java
@@ -36,6 +36,8 @@ import 
org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId;
              category = { Category.IOT })
 public class MiloClientEndpoint extends DefaultEndpoint {
 
+    private final MiloClientConnectionManager connectionManager;
+
     /**
      * The OPC UA server endpoint
      */
@@ -79,8 +81,6 @@ public class MiloClientEndpoint extends DefaultEndpoint {
     @UriParam
     private MonitorFilterType monitorFilterType;
 
-    private MiloClientConnectionManager connectionManager;
-
     public MiloClientEndpoint(final String uri, final MiloClientComponent 
component, final String endpointUri,
                               final MiloClientConnectionManager 
connectionManager) {
         super(uri, component);
diff --git 
a/components/camel-milo/src/test/java/org/apache/camel/component/milo/MiloClientCachingConnectionManagerTest.java
 
b/components/camel-milo/src/test/java/org/apache/camel/component/milo/MiloClientCachingConnectionManagerTest.java
index c60086b..73e1fdc 100644
--- 
a/components/camel-milo/src/test/java/org/apache/camel/component/milo/MiloClientCachingConnectionManagerTest.java
+++ 
b/components/camel-milo/src/test/java/org/apache/camel/component/milo/MiloClientCachingConnectionManagerTest.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.camel.component.milo;
 
 import 
org.apache.camel.component.milo.client.MiloClientCachingConnectionManager;
@@ -13,12 +29,12 @@ public class MiloClientCachingConnectionManagerTest {
     private MiloClientCachingConnectionManager instance;
 
     @BeforeEach
-    void setup() {
+    public void setup() {
         instance = new MiloClientCachingConnectionManager();
     }
 
     @Test
-    void testCreateConnection_reuseConnection() {
+    public void testCreateConnectionReuseConnection() {
         final MiloClientConfiguration configuration = new 
MiloClientConfiguration();
 
         MiloClientConnection connection1 = 
instance.createConnection(configuration, new MonitorFilterConfiguration());
@@ -30,7 +46,7 @@ public class MiloClientCachingConnectionManagerTest {
     }
 
     @Test
-    void releaseConnection_notLastConsumer() throws Exception {
+    public void testReleaseConnectionNotLastConsumer() throws Exception {
         final MiloClientConfiguration configuration = new 
MiloClientConfiguration();
         MiloClientConnection connection1 = 
instance.createConnection(configuration, new MonitorFilterConfiguration());
         instance.createConnection(configuration, new 
MonitorFilterConfiguration());
@@ -42,7 +58,7 @@ public class MiloClientCachingConnectionManagerTest {
     }
 
     @Test
-    void releaseConnection_lastConsumer() throws Exception {
+    public void testReleaseConnectionLastConsumer() throws Exception {
         final MiloClientConfiguration configuration = new 
MiloClientConfiguration();
         MiloClientConnection connection1 = 
instance.createConnection(configuration, new MonitorFilterConfiguration());
         MiloClientConnection connection2 = 
instance.createConnection(configuration, new MonitorFilterConfiguration());
diff --git 
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MiloClientComponentBuilderFactory.java
 
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MiloClientComponentBuilderFactory.java
index 15b814c..41e8d8c4 100644
--- 
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MiloClientComponentBuilderFactory.java
+++ 
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MiloClientComponentBuilderFactory.java
@@ -114,22 +114,6 @@ public interface MiloClientComponentBuilderFactory {
             return this;
         }
         /**
-         * Instance for managing client connections.
-         * 
-         * The option is a:
-         * 
&lt;code&gt;org.apache.camel.component.milo.client.MiloClientConnectionManager&lt;/code&gt;
 type.
-         * 
-         * Group: common
-         * 
-         * @param miloClientCachingConnectionManager the value to set
-         * @return the dsl builder
-         */
-        default MiloClientComponentBuilder miloClientCachingConnectionManager(
-                
org.apache.camel.component.milo.client.MiloClientConnectionManager 
miloClientCachingConnectionManager) {
-            doSetProperty("miloClientCachingConnectionManager", 
miloClientCachingConnectionManager);
-            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
@@ -364,6 +348,22 @@ public interface MiloClientComponentBuilderFactory {
             return this;
         }
         /**
+         * Instance for managing client connections.
+         * 
+         * The option is a:
+         * 
&lt;code&gt;org.apache.camel.component.milo.client.MiloClientConnectionManager&lt;/code&gt;
 type.
+         * 
+         * Group: client
+         * 
+         * @param miloClientConnectionManager the value to set
+         * @return the dsl builder
+         */
+        default MiloClientComponentBuilder miloClientConnectionManager(
+                
org.apache.camel.component.milo.client.MiloClientConnectionManager 
miloClientConnectionManager) {
+            doSetProperty("miloClientConnectionManager", 
miloClientConnectionManager);
+            return this;
+        }
+        /**
          * Override the server reported endpoint host with the host from the
          * endpoint URI.
          * 
@@ -484,7 +484,6 @@ public interface MiloClientComponentBuilderFactory {
             case "configuration": ((MiloClientComponent) 
component).setConfiguration((org.apache.camel.component.milo.client.MiloClientConfiguration)
 value); return true;
             case "discoveryEndpointSuffix": 
getOrCreateConfiguration((MiloClientComponent) 
component).setDiscoveryEndpointSuffix((java.lang.String) value); return true;
             case "discoveryEndpointUri": 
getOrCreateConfiguration((MiloClientComponent) 
component).setDiscoveryEndpointUri((java.lang.String) value); return true;
-            case "miloClientCachingConnectionManager": ((MiloClientComponent) 
component).setMiloClientCachingConnectionManager((org.apache.camel.component.milo.client.MiloClientConnectionManager)
 value); return true;
             case "bridgeErrorHandler": ((MiloClientComponent) 
component).setBridgeErrorHandler((boolean) value); return true;
             case "lazyStartProducer": ((MiloClientComponent) 
component).setLazyStartProducer((boolean) value); return true;
             case "autowiredEnabled": ((MiloClientComponent) 
component).setAutowiredEnabled((boolean) value); return true;
@@ -499,6 +498,7 @@ public interface MiloClientComponentBuilderFactory {
             case "keyStoreUrl": getOrCreateConfiguration((MiloClientComponent) 
component).setKeyStoreUrl((java.lang.String) value); return true;
             case "maxPendingPublishRequests": 
getOrCreateConfiguration((MiloClientComponent) 
component).setMaxPendingPublishRequests((java.lang.Long) value); return true;
             case "maxResponseMessageSize": 
getOrCreateConfiguration((MiloClientComponent) 
component).setMaxResponseMessageSize((java.lang.Long) value); return true;
+            case "miloClientConnectionManager": ((MiloClientComponent) 
component).setMiloClientConnectionManager((org.apache.camel.component.milo.client.MiloClientConnectionManager)
 value); return true;
             case "overrideHost": 
getOrCreateConfiguration((MiloClientComponent) 
component).setOverrideHost((boolean) value); return true;
             case "productUri": getOrCreateConfiguration((MiloClientComponent) 
component).setProductUri((java.lang.String) value); return true;
             case "requestedPublishingInterval": 
getOrCreateConfiguration((MiloClientComponent) 
component).setRequestedPublishingInterval((java.lang.Double) value); return 
true;
diff --git a/docs/components/modules/ROOT/pages/milo-client-component.adoc 
b/docs/components/modules/ROOT/pages/milo-client-component.adoc
index f21de4b..354835c 100644
--- a/docs/components/modules/ROOT/pages/milo-client-component.adoc
+++ b/docs/components/modules/ROOT/pages/milo-client-component.adoc
@@ -46,7 +46,6 @@ The OPC UA Client component supports 25 options, which are 
listed below.
 | *configuration* (common) | All default options for client configurations |  
| MiloClientConfiguration
 | *discoveryEndpointSuffix* (common) | A suffix for endpoint URI when 
discovering |  | String
 | *discoveryEndpointUri* (common) | An alternative discovery URI |  | String
-| *miloClientCachingConnection{zwsp}Manager* (common) | Instance for managing 
client connections. |  | MiloClientConnectionManager
 | *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 [...]
 | *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used 
for automatic autowiring options (the option must be marked as autowired) by 
looking up in the registry to find if there is a single instance of matching 
type, which then gets configured on the component. This can be used for 
automatic configuring JDBC data sources, JMS connection factories, AWS Clients, 
etc. | true | boolean
@@ -61,6 +60,7 @@ The OPC UA Client component supports 25 options, which are 
listed below.
 | *keyStoreUrl* (client) | The URL where the key should be loaded from |  | 
String
 | *maxPendingPublishRequests* (client) | The maximum number of pending publish 
requests |  | Long
 | *maxResponseMessageSize* (client) | The maximum number of bytes a response 
message may have |  | Long
+| *miloClientConnectionManager* (client) | *Autowired* Instance for managing 
client connections |  | MiloClientConnectionManager
 | *overrideHost* (client) | Override the server reported endpoint host with 
the host from the endpoint URI. | false | boolean
 | *productUri* (client) | The product URI | 
http://camel.apache.org/EclipseMilo | String
 | *requestedPublishingInterval* (client) | The requested publishing interval 
in milliseconds | 1_000.0 | Double

Reply via email to