This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch ra in repository https://gitbox.apache.org/repos/asf/camel.git
commit ab75140bb048179a292e08af685ec7f35252dad3 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue May 28 08:15:41 2024 +0200 CAMEL-20798: Add RemoteAddress to endpoints so they can tell the url/hostname etc for the system it connects. This is needed for better monitoring, tracing and management. Add this information into camel-tracer as tags. --- .../apache/camel/catalog/components/mongodb.json | 24 +++---- .../component/debezium/DebeziumDb2Endpoint.java | 23 +++++- .../debezium/DebeziumMongodbEndpoint.java | 23 +++++- .../component/debezium/DebeziumMySqlEndpoint.java | 23 +++++- .../component/debezium/DebeziumOracleEndpoint.java | 23 +++++- .../debezium/DebeziumPostgresEndpoint.java | 23 +++++- .../debezium/DebeziumSqlserverEndpoint.java | 23 +++++- .../apache/camel/component/mongodb/mongodb.json | 24 +++---- .../camel/component/mongodb/MongoDbEndpoint.java | 28 +++++++- .../dsl/MongoDbEndpointBuilderFactory.java | 84 +++++++++++----------- .../camel/kotlin/components/MongodbUriDsl.kt | 14 ++-- 11 files changed, 231 insertions(+), 81 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mongodb.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mongodb.json index 048be7fa46e..1b0286db7ff 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mongodb.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/mongodb.json @@ -60,18 +60,18 @@ "connectionBean": { "index": 0, "kind": "path", "displayName": "Connection Bean", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets the connection bean reference used to lookup a client for connecting to a database if no hosts parameter is present." }, "collection": { "index": 1, "kind": "parameter", "displayName": "Collection", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the MongoDB collection to bind to this endpoint" }, "collectionIndex": { "index": 2, "kind": "parameter", "displayName": "Collection Index", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the collection index (JSON FORMAT : { field1 : order1, field2 : order2})" }, - "createCollection": { "index": 3, "kind": "parameter", "displayName": "Create Collection", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Create collection during initialisation if it doesn't exist. Default is true." }, - "database": { "index": 4, "kind": "parameter", "displayName": "Database", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the MongoDB database to target" }, - "hosts": { "index": 5, "kind": "parameter", "displayName": "Hosts", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Host address of mongodb server in host:port format. It's possible also use more than one address, as comma separated list of hosts: host1:port1,host2:port2. If the hosts parameter is specified, the provided connectionBean is ignored." }, - "mongoConnection": { "index": 6, "kind": "parameter", "displayName": "Mongo Connection", "group": "common", "label": "", "required": false, "type": "object", "javaType": "com.mongodb.client.MongoClient", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the connection bean used as a client for connecting to a database." }, - "operation": { "index": 7, "kind": "parameter", "displayName": "Operation", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.mongodb.MongoDbOperation", "enum": [ "findById", "findOneAndDelete", "findOneAndReplace", "findOneAndUpdate", "findOneByQuery", "findAll", "findDistinct", "insert", "save", "update", "remove", "bulkWrite", "aggregate", "getDbStats", "getColStats", "count", "command" ], "deprecated": false, "autowired": [...] - "outputType": { "index": 8, "kind": "parameter", "displayName": "Output Type", "group": "common", "label": "common", "required": false, "type": "object", "javaType": "org.apache.camel.component.mongodb.MongoDbOutputType", "enum": [ "DocumentList", "Document", "MongoIterable" ], "deprecated": false, "autowired": false, "secret": false, "description": "Convert the output of the producer to the selected type : DocumentList Document or MongoIterable. DocumentList or MongoIterable applies [...] - "consumerType": { "index": 9, "kind": "parameter", "displayName": "Consumer Type", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Consumer type." }, - "bridgeErrorHandler": { "index": 10, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 (if possible) occurred while the Camel consumer is trying to pickup incoming [...] - "exceptionHandler": { "index": 11, "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By de [...] - "exchangePattern": { "index": 12, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, - "lazyStartProducer": { "index": 13, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "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 produ [...] - "connectionUriString": { "index": 14, "kind": "parameter", "displayName": "Connection Uri String", "group": "additional", "label": "additional", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Set the whole Connection String\/Uri for mongodb endpoint." }, + "connectionUriString": { "index": 3, "kind": "parameter", "displayName": "Connection Uri String", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Set the whole Connection String\/Uri for mongodb endpoint." }, + "createCollection": { "index": 4, "kind": "parameter", "displayName": "Create Collection", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Create collection during initialisation if it doesn't exist. Default is true." }, + "database": { "index": 5, "kind": "parameter", "displayName": "Database", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the MongoDB database to target" }, + "hosts": { "index": 6, "kind": "parameter", "displayName": "Hosts", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Host address of mongodb server in host:port format. It's possible also use more than one address, as comma separated list of hosts: host1:port1,host2:port2. If the hosts parameter is specified, the provided connectionBean is ignored." }, + "mongoConnection": { "index": 7, "kind": "parameter", "displayName": "Mongo Connection", "group": "common", "label": "", "required": false, "type": "object", "javaType": "com.mongodb.client.MongoClient", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the connection bean used as a client for connecting to a database." }, + "operation": { "index": 8, "kind": "parameter", "displayName": "Operation", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.mongodb.MongoDbOperation", "enum": [ "findById", "findOneAndDelete", "findOneAndReplace", "findOneAndUpdate", "findOneByQuery", "findAll", "findDistinct", "insert", "save", "update", "remove", "bulkWrite", "aggregate", "getDbStats", "getColStats", "count", "command" ], "deprecated": false, "autowired": [...] + "outputType": { "index": 9, "kind": "parameter", "displayName": "Output Type", "group": "common", "label": "common", "required": false, "type": "object", "javaType": "org.apache.camel.component.mongodb.MongoDbOutputType", "enum": [ "DocumentList", "Document", "MongoIterable" ], "deprecated": false, "autowired": false, "secret": false, "description": "Convert the output of the producer to the selected type : DocumentList Document or MongoIterable. DocumentList or MongoIterable applies [...] + "consumerType": { "index": 10, "kind": "parameter", "displayName": "Consumer Type", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Consumer type." }, + "bridgeErrorHandler": { "index": 11, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 (if possible) occurred while the Camel consumer is trying to pickup incoming [...] + "exceptionHandler": { "index": 12, "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By de [...] + "exchangePattern": { "index": 13, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, + "lazyStartProducer": { "index": 14, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "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 produ [...] "appName": { "index": 15, "kind": "parameter", "displayName": "App Name", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the logical name of the application. The application name may be used by the client to identify the application to the server, for use in server logs, slow query logs, and profile collection. Default: null" }, "compressors": { "index": 16, "kind": "parameter", "displayName": "Compressors", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Specifies one or more compression algorithms that the driver will attempt to use to compress requests sent to the connected MongoDB instance. Possible values include: zlib, snappy, and zstd. Default: null" }, "connectTimeoutMS": { "index": 17, "kind": "parameter", "displayName": "Connect Timeout MS", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "10000", "description": "Specifies the maximum amount of time, in milliseconds, the Java driver waits for a connection to open before timing out. A value of 0 instructs the driver to never time out while wait [...] diff --git a/components/camel-debezium/camel-debezium-db2/src/main/java/org/apache/camel/component/debezium/DebeziumDb2Endpoint.java b/components/camel-debezium/camel-debezium-db2/src/main/java/org/apache/camel/component/debezium/DebeziumDb2Endpoint.java index 30e8c5f85fc..2d5a27fcca4 100644 --- a/components/camel-debezium/camel-debezium-db2/src/main/java/org/apache/camel/component/debezium/DebeziumDb2Endpoint.java +++ b/components/camel-debezium/camel-debezium-db2/src/main/java/org/apache/camel/component/debezium/DebeziumDb2Endpoint.java @@ -19,16 +19,19 @@ package org.apache.camel.component.debezium; import org.apache.camel.Category; import org.apache.camel.component.debezium.configuration.Db2ConnectorEmbeddedDebeziumConfiguration; +import org.apache.camel.spi.EndpointServiceLocation; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; +import java.util.Map; + /** * Capture changes from a DB2 database. */ @UriEndpoint(firstVersion = "3.17.0", scheme = "debezium-db2", title = "Debezium DB2 Connector", syntax = "debezium-db2:name", category = { Category.DATABASE }, consumerOnly = true, headersClass = DebeziumConstants.class) -public final class DebeziumDb2Endpoint extends DebeziumEndpoint<Db2ConnectorEmbeddedDebeziumConfiguration> { +public final class DebeziumDb2Endpoint extends DebeziumEndpoint<Db2ConnectorEmbeddedDebeziumConfiguration> implements EndpointServiceLocation { @UriParam private Db2ConnectorEmbeddedDebeziumConfiguration configuration; @@ -42,6 +45,24 @@ public final class DebeziumDb2Endpoint extends DebeziumEndpoint<Db2ConnectorEmbe public DebeziumDb2Endpoint() { } + @Override + public String getServiceUrl() { + return configuration.getDatabaseHostname() + ":" + configuration.getDatabasePort(); + } + + @Override + public String getServiceProtocol() { + return "jdbc"; + } + + @Override + public Map<String, String> getServiceMetadata() { + if (configuration.getDatabaseUser() != null) { + return Map.of("username", configuration.getDatabaseUser()); + } + return null; + } + @Override public Db2ConnectorEmbeddedDebeziumConfiguration getConfiguration() { return configuration; diff --git a/components/camel-debezium/camel-debezium-mongodb/src/main/java/org/apache/camel/component/debezium/DebeziumMongodbEndpoint.java b/components/camel-debezium/camel-debezium-mongodb/src/main/java/org/apache/camel/component/debezium/DebeziumMongodbEndpoint.java index 0a7442a2f07..0099c5dff1f 100644 --- a/components/camel-debezium/camel-debezium-mongodb/src/main/java/org/apache/camel/component/debezium/DebeziumMongodbEndpoint.java +++ b/components/camel-debezium/camel-debezium-mongodb/src/main/java/org/apache/camel/component/debezium/DebeziumMongodbEndpoint.java @@ -19,17 +19,20 @@ package org.apache.camel.component.debezium; import io.debezium.data.Envelope; import org.apache.camel.Category; import org.apache.camel.component.debezium.configuration.MongoDbConnectorEmbeddedDebeziumConfiguration; +import org.apache.camel.spi.EndpointServiceLocation; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.kafka.connect.data.Schema; +import java.util.Map; + /** * Capture changes from a MongoDB database. */ @UriEndpoint(firstVersion = "3.0.0", scheme = "debezium-mongodb", title = "Debezium MongoDB Connector", syntax = "debezium-mongodb:name", category = { Category.DATABASE }, consumerOnly = true, headersClass = DebeziumConstants.class) -public final class DebeziumMongodbEndpoint extends DebeziumEndpoint<MongoDbConnectorEmbeddedDebeziumConfiguration> { +public final class DebeziumMongodbEndpoint extends DebeziumEndpoint<MongoDbConnectorEmbeddedDebeziumConfiguration> implements EndpointServiceLocation { @UriParam private MongoDbConnectorEmbeddedDebeziumConfiguration configuration; @@ -43,6 +46,24 @@ public final class DebeziumMongodbEndpoint extends DebeziumEndpoint<MongoDbConne public DebeziumMongodbEndpoint() { } + @Override + public String getServiceUrl() { + return configuration.getMongodbConnectionString(); + } + + @Override + public String getServiceProtocol() { + return "mongodb"; + } + + @Override + public Map<String, String> getServiceMetadata() { + if (configuration.getMongodbUser() != null) { + return Map.of("username", configuration.getMongodbUser()); + } + return null; + } + @Override public MongoDbConnectorEmbeddedDebeziumConfiguration getConfiguration() { return configuration; diff --git a/components/camel-debezium/camel-debezium-mysql/src/main/java/org/apache/camel/component/debezium/DebeziumMySqlEndpoint.java b/components/camel-debezium/camel-debezium-mysql/src/main/java/org/apache/camel/component/debezium/DebeziumMySqlEndpoint.java index 964554a4c89..0a267d91fb1 100644 --- a/components/camel-debezium/camel-debezium-mysql/src/main/java/org/apache/camel/component/debezium/DebeziumMySqlEndpoint.java +++ b/components/camel-debezium/camel-debezium-mysql/src/main/java/org/apache/camel/component/debezium/DebeziumMySqlEndpoint.java @@ -18,16 +18,19 @@ package org.apache.camel.component.debezium; import org.apache.camel.Category; import org.apache.camel.component.debezium.configuration.MySqlConnectorEmbeddedDebeziumConfiguration; +import org.apache.camel.spi.EndpointServiceLocation; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; +import java.util.Map; + /** * Capture changes from a MySQL database. */ @UriEndpoint(firstVersion = "3.0.0", scheme = "debezium-mysql", title = "Debezium MySQL Connector", syntax = "debezium-mysql:name", category = { Category.DATABASE }, consumerOnly = true, headersClass = DebeziumConstants.class) -public final class DebeziumMySqlEndpoint extends DebeziumEndpoint<MySqlConnectorEmbeddedDebeziumConfiguration> { +public final class DebeziumMySqlEndpoint extends DebeziumEndpoint<MySqlConnectorEmbeddedDebeziumConfiguration> implements EndpointServiceLocation { @UriParam private MySqlConnectorEmbeddedDebeziumConfiguration configuration; @@ -41,6 +44,24 @@ public final class DebeziumMySqlEndpoint extends DebeziumEndpoint<MySqlConnector public DebeziumMySqlEndpoint() { } + @Override + public String getServiceUrl() { + return configuration.getDatabaseHostname() + ":" + configuration.getDatabasePort(); + } + + @Override + public String getServiceProtocol() { + return "jdbc"; + } + + @Override + public Map<String, String> getServiceMetadata() { + if (configuration.getDatabaseUser() != null) { + return Map.of("username", configuration.getDatabaseUser()); + } + return null; + } + @Override public MySqlConnectorEmbeddedDebeziumConfiguration getConfiguration() { return configuration; diff --git a/components/camel-debezium/camel-debezium-oracle/src/main/java/org/apache/camel/component/debezium/DebeziumOracleEndpoint.java b/components/camel-debezium/camel-debezium-oracle/src/main/java/org/apache/camel/component/debezium/DebeziumOracleEndpoint.java index 45941edd823..8b47d211ee1 100644 --- a/components/camel-debezium/camel-debezium-oracle/src/main/java/org/apache/camel/component/debezium/DebeziumOracleEndpoint.java +++ b/components/camel-debezium/camel-debezium-oracle/src/main/java/org/apache/camel/component/debezium/DebeziumOracleEndpoint.java @@ -19,16 +19,19 @@ package org.apache.camel.component.debezium; import org.apache.camel.Category; import org.apache.camel.component.debezium.configuration.OracleConnectorEmbeddedDebeziumConfiguration; +import org.apache.camel.spi.EndpointServiceLocation; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; +import java.util.Map; + /** * Capture changes from a Oracle database. */ @UriEndpoint(firstVersion = "3.17.0", scheme = "debezium-oracle", title = "Debezium Oracle Connector", syntax = "debezium-oracle:name", category = { Category.DATABASE }, consumerOnly = true, headersClass = DebeziumConstants.class) -public final class DebeziumOracleEndpoint extends DebeziumEndpoint<OracleConnectorEmbeddedDebeziumConfiguration> { +public final class DebeziumOracleEndpoint extends DebeziumEndpoint<OracleConnectorEmbeddedDebeziumConfiguration> implements EndpointServiceLocation { @UriParam private OracleConnectorEmbeddedDebeziumConfiguration configuration; @@ -42,6 +45,24 @@ public final class DebeziumOracleEndpoint extends DebeziumEndpoint<OracleConnect public DebeziumOracleEndpoint() { } + @Override + public String getServiceUrl() { + return configuration.getDatabaseHostname() + ":" + configuration.getDatabasePort(); + } + + @Override + public String getServiceProtocol() { + return "jdbc"; + } + + @Override + public Map<String, String> getServiceMetadata() { + if (configuration.getDatabaseUser() != null) { + return Map.of("username", configuration.getDatabaseUser()); + } + return null; + } + @Override public OracleConnectorEmbeddedDebeziumConfiguration getConfiguration() { return configuration; diff --git a/components/camel-debezium/camel-debezium-postgres/src/main/java/org/apache/camel/component/debezium/DebeziumPostgresEndpoint.java b/components/camel-debezium/camel-debezium-postgres/src/main/java/org/apache/camel/component/debezium/DebeziumPostgresEndpoint.java index b9204ffd18e..2c4325a4255 100644 --- a/components/camel-debezium/camel-debezium-postgres/src/main/java/org/apache/camel/component/debezium/DebeziumPostgresEndpoint.java +++ b/components/camel-debezium/camel-debezium-postgres/src/main/java/org/apache/camel/component/debezium/DebeziumPostgresEndpoint.java @@ -18,16 +18,19 @@ package org.apache.camel.component.debezium; import org.apache.camel.Category; import org.apache.camel.component.debezium.configuration.PostgresConnectorEmbeddedDebeziumConfiguration; +import org.apache.camel.spi.EndpointServiceLocation; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; +import java.util.Map; + /** * Capture changes from a PostgresSQL database. */ @UriEndpoint(firstVersion = "3.0.0", scheme = "debezium-postgres", title = "Debezium PostgresSQL Connector", syntax = "debezium-postgres:name", category = { Category.DATABASE }, consumerOnly = true, headersClass = DebeziumConstants.class) -public final class DebeziumPostgresEndpoint extends DebeziumEndpoint<PostgresConnectorEmbeddedDebeziumConfiguration> { +public final class DebeziumPostgresEndpoint extends DebeziumEndpoint<PostgresConnectorEmbeddedDebeziumConfiguration> implements EndpointServiceLocation { @UriParam private PostgresConnectorEmbeddedDebeziumConfiguration configuration; @@ -41,6 +44,24 @@ public final class DebeziumPostgresEndpoint extends DebeziumEndpoint<PostgresCon public DebeziumPostgresEndpoint() { } + @Override + public String getServiceUrl() { + return configuration.getDatabaseHostname() + ":" + configuration.getDatabasePort(); + } + + @Override + public String getServiceProtocol() { + return "jdbc"; + } + + @Override + public Map<String, String> getServiceMetadata() { + if (configuration.getDatabaseUser() != null) { + return Map.of("username", configuration.getDatabaseUser()); + } + return null; + } + @Override public PostgresConnectorEmbeddedDebeziumConfiguration getConfiguration() { return configuration; diff --git a/components/camel-debezium/camel-debezium-sqlserver/src/main/java/org/apache/camel/component/debezium/DebeziumSqlserverEndpoint.java b/components/camel-debezium/camel-debezium-sqlserver/src/main/java/org/apache/camel/component/debezium/DebeziumSqlserverEndpoint.java index 06c8b161c1c..511bd3c3fcc 100644 --- a/components/camel-debezium/camel-debezium-sqlserver/src/main/java/org/apache/camel/component/debezium/DebeziumSqlserverEndpoint.java +++ b/components/camel-debezium/camel-debezium-sqlserver/src/main/java/org/apache/camel/component/debezium/DebeziumSqlserverEndpoint.java @@ -18,16 +18,19 @@ package org.apache.camel.component.debezium; import org.apache.camel.Category; import org.apache.camel.component.debezium.configuration.SqlServerConnectorEmbeddedDebeziumConfiguration; +import org.apache.camel.spi.EndpointServiceLocation; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; +import java.util.Map; + /** * Capture changes from an SQL Server database. */ @UriEndpoint(firstVersion = "3.0.0", scheme = "debezium-sqlserver", title = "Debezium SQL Server Connector", syntax = "debezium-sqlserver:name", category = { Category.DATABASE }, consumerOnly = true, headersClass = DebeziumConstants.class) -public final class DebeziumSqlserverEndpoint extends DebeziumEndpoint<SqlServerConnectorEmbeddedDebeziumConfiguration> { +public final class DebeziumSqlserverEndpoint extends DebeziumEndpoint<SqlServerConnectorEmbeddedDebeziumConfiguration> implements EndpointServiceLocation { @UriParam private SqlServerConnectorEmbeddedDebeziumConfiguration configuration; @@ -41,6 +44,24 @@ public final class DebeziumSqlserverEndpoint extends DebeziumEndpoint<SqlServerC public DebeziumSqlserverEndpoint() { } + @Override + public String getServiceUrl() { + return configuration.getDatabaseHostname() + ":" + configuration.getDatabasePort(); + } + + @Override + public String getServiceProtocol() { + return "jdbc"; + } + + @Override + public Map<String, String> getServiceMetadata() { + if (configuration.getDatabaseUser() != null) { + return Map.of("username", configuration.getDatabaseUser()); + } + return null; + } + @Override public SqlServerConnectorEmbeddedDebeziumConfiguration getConfiguration() { return configuration; diff --git a/components/camel-mongodb/src/generated/resources/META-INF/org/apache/camel/component/mongodb/mongodb.json b/components/camel-mongodb/src/generated/resources/META-INF/org/apache/camel/component/mongodb/mongodb.json index 048be7fa46e..1b0286db7ff 100644 --- a/components/camel-mongodb/src/generated/resources/META-INF/org/apache/camel/component/mongodb/mongodb.json +++ b/components/camel-mongodb/src/generated/resources/META-INF/org/apache/camel/component/mongodb/mongodb.json @@ -60,18 +60,18 @@ "connectionBean": { "index": 0, "kind": "path", "displayName": "Connection Bean", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets the connection bean reference used to lookup a client for connecting to a database if no hosts parameter is present." }, "collection": { "index": 1, "kind": "parameter", "displayName": "Collection", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the MongoDB collection to bind to this endpoint" }, "collectionIndex": { "index": 2, "kind": "parameter", "displayName": "Collection Index", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the collection index (JSON FORMAT : { field1 : order1, field2 : order2})" }, - "createCollection": { "index": 3, "kind": "parameter", "displayName": "Create Collection", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Create collection during initialisation if it doesn't exist. Default is true." }, - "database": { "index": 4, "kind": "parameter", "displayName": "Database", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the MongoDB database to target" }, - "hosts": { "index": 5, "kind": "parameter", "displayName": "Hosts", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Host address of mongodb server in host:port format. It's possible also use more than one address, as comma separated list of hosts: host1:port1,host2:port2. If the hosts parameter is specified, the provided connectionBean is ignored." }, - "mongoConnection": { "index": 6, "kind": "parameter", "displayName": "Mongo Connection", "group": "common", "label": "", "required": false, "type": "object", "javaType": "com.mongodb.client.MongoClient", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the connection bean used as a client for connecting to a database." }, - "operation": { "index": 7, "kind": "parameter", "displayName": "Operation", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.mongodb.MongoDbOperation", "enum": [ "findById", "findOneAndDelete", "findOneAndReplace", "findOneAndUpdate", "findOneByQuery", "findAll", "findDistinct", "insert", "save", "update", "remove", "bulkWrite", "aggregate", "getDbStats", "getColStats", "count", "command" ], "deprecated": false, "autowired": [...] - "outputType": { "index": 8, "kind": "parameter", "displayName": "Output Type", "group": "common", "label": "common", "required": false, "type": "object", "javaType": "org.apache.camel.component.mongodb.MongoDbOutputType", "enum": [ "DocumentList", "Document", "MongoIterable" ], "deprecated": false, "autowired": false, "secret": false, "description": "Convert the output of the producer to the selected type : DocumentList Document or MongoIterable. DocumentList or MongoIterable applies [...] - "consumerType": { "index": 9, "kind": "parameter", "displayName": "Consumer Type", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Consumer type." }, - "bridgeErrorHandler": { "index": 10, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 (if possible) occurred while the Camel consumer is trying to pickup incoming [...] - "exceptionHandler": { "index": 11, "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By de [...] - "exchangePattern": { "index": 12, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, - "lazyStartProducer": { "index": 13, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "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 produ [...] - "connectionUriString": { "index": 14, "kind": "parameter", "displayName": "Connection Uri String", "group": "additional", "label": "additional", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Set the whole Connection String\/Uri for mongodb endpoint." }, + "connectionUriString": { "index": 3, "kind": "parameter", "displayName": "Connection Uri String", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Set the whole Connection String\/Uri for mongodb endpoint." }, + "createCollection": { "index": 4, "kind": "parameter", "displayName": "Create Collection", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Create collection during initialisation if it doesn't exist. Default is true." }, + "database": { "index": 5, "kind": "parameter", "displayName": "Database", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the MongoDB database to target" }, + "hosts": { "index": 6, "kind": "parameter", "displayName": "Hosts", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Host address of mongodb server in host:port format. It's possible also use more than one address, as comma separated list of hosts: host1:port1,host2:port2. If the hosts parameter is specified, the provided connectionBean is ignored." }, + "mongoConnection": { "index": 7, "kind": "parameter", "displayName": "Mongo Connection", "group": "common", "label": "", "required": false, "type": "object", "javaType": "com.mongodb.client.MongoClient", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the connection bean used as a client for connecting to a database." }, + "operation": { "index": 8, "kind": "parameter", "displayName": "Operation", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.mongodb.MongoDbOperation", "enum": [ "findById", "findOneAndDelete", "findOneAndReplace", "findOneAndUpdate", "findOneByQuery", "findAll", "findDistinct", "insert", "save", "update", "remove", "bulkWrite", "aggregate", "getDbStats", "getColStats", "count", "command" ], "deprecated": false, "autowired": [...] + "outputType": { "index": 9, "kind": "parameter", "displayName": "Output Type", "group": "common", "label": "common", "required": false, "type": "object", "javaType": "org.apache.camel.component.mongodb.MongoDbOutputType", "enum": [ "DocumentList", "Document", "MongoIterable" ], "deprecated": false, "autowired": false, "secret": false, "description": "Convert the output of the producer to the selected type : DocumentList Document or MongoIterable. DocumentList or MongoIterable applies [...] + "consumerType": { "index": 10, "kind": "parameter", "displayName": "Consumer Type", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Consumer type." }, + "bridgeErrorHandler": { "index": 11, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 (if possible) occurred while the Camel consumer is trying to pickup incoming [...] + "exceptionHandler": { "index": 12, "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By de [...] + "exchangePattern": { "index": 13, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, + "lazyStartProducer": { "index": 14, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "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 produ [...] "appName": { "index": 15, "kind": "parameter", "displayName": "App Name", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the logical name of the application. The application name may be used by the client to identify the application to the server, for use in server logs, slow query logs, and profile collection. Default: null" }, "compressors": { "index": 16, "kind": "parameter", "displayName": "Compressors", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Specifies one or more compression algorithms that the driver will attempt to use to compress requests sent to the connected MongoDB instance. Possible values include: zlib, snappy, and zstd. Default: null" }, "connectTimeoutMS": { "index": 17, "kind": "parameter", "displayName": "Connect Timeout MS", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "10000", "description": "Specifies the maximum amount of time, in milliseconds, the Java driver waits for a connection to open before timing out. A value of 0 instructs the driver to never time out while wait [...] diff --git a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java index a8c6eefc9a2..09879330689 100644 --- a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java +++ b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java @@ -35,6 +35,7 @@ import org.apache.camel.Category; import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; +import org.apache.camel.spi.EndpointServiceLocation; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -60,7 +61,7 @@ import static org.apache.camel.component.mongodb.MongoDbOutputType.MongoIterable */ @UriEndpoint(firstVersion = "2.19.0", scheme = "mongodb", title = "MongoDB", syntax = "mongodb:connectionBean", category = { Category.DATABASE }, headersClass = MongoDbConstants.class) -public class MongoDbEndpoint extends DefaultEndpoint { +public class MongoDbEndpoint extends DefaultEndpoint implements EndpointServiceLocation { private static final Logger LOG = LoggerFactory.getLogger(MongoDbEndpoint.class); @@ -187,7 +188,7 @@ public class MongoDbEndpoint extends DefaultEndpoint { private boolean loadBalanced; //additional properties @UriParam(description = "Set the whole Connection String/Uri for mongodb endpoint.", - label = "additional", defaultValue = "null") + label = "common") private String connectionUriString; // tailable cursor consumer by default @@ -205,6 +206,29 @@ public class MongoDbEndpoint extends DefaultEndpoint { super(uri, component); } + @Override + public String getServiceUrl() { + if (connectionUriString != null) { + return connectionUriString; + } else if (hosts != null) { + return hosts; + } + return null; + } + + @Override + public String getServiceProtocol() { + return "mongodb"; + } + + @Override + public Map<String, String> getServiceMetadata() { + if (username != null) { + return Map.of("username", username); + } + return null; + } + @Override public Producer createProducer() { validateProducerOptions(); diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MongoDbEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MongoDbEndpointBuilderFactory.java index d3020d8ca9e..ec8aae805a8 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MongoDbEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MongoDbEndpointBuilderFactory.java @@ -72,6 +72,20 @@ public interface MongoDbEndpointBuilderFactory { doSetProperty("collectionIndex", collectionIndex); return this; } + /** + * Set the whole Connection String/Uri for mongodb endpoint. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: common + * + * @param connectionUriString the value to set + * @return the dsl builder + */ + default MongoDbEndpointConsumerBuilder connectionUriString(String connectionUriString) { + doSetProperty("connectionUriString", connectionUriString); + return this; + } /** * Create collection during initialisation if it doesn't exist. Default * is true. @@ -250,20 +264,6 @@ public interface MongoDbEndpointBuilderFactory { doSetProperty("consumerType", consumerType); return this; } - /** - * Set the whole Connection String/Uri for mongodb endpoint. - * - * The option is a: <code>java.lang.String</code> type. - * - * Group: additional - * - * @param connectionUriString the value to set - * @return the dsl builder - */ - default MongoDbEndpointConsumerBuilder connectionUriString(String connectionUriString) { - doSetProperty("connectionUriString", connectionUriString); - return this; - } /** * Specifies whether changeStream consumer include a copy of the full * document when modified by update operations. Possible values are @@ -1574,6 +1574,20 @@ public interface MongoDbEndpointBuilderFactory { doSetProperty("collectionIndex", collectionIndex); return this; } + /** + * Set the whole Connection String/Uri for mongodb endpoint. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: common + * + * @param connectionUriString the value to set + * @return the dsl builder + */ + default MongoDbEndpointProducerBuilder connectionUriString(String connectionUriString) { + doSetProperty("connectionUriString", connectionUriString); + return this; + } /** * Create collection during initialisation if it doesn't exist. Default * is true. @@ -1738,20 +1752,6 @@ public interface MongoDbEndpointBuilderFactory { doSetProperty("outputType", outputType); return this; } - /** - * Set the whole Connection String/Uri for mongodb endpoint. - * - * The option is a: <code>java.lang.String</code> type. - * - * Group: additional - * - * @param connectionUriString the value to set - * @return the dsl builder - */ - default MongoDbEndpointProducerBuilder connectionUriString(String connectionUriString) { - doSetProperty("connectionUriString", connectionUriString); - return this; - } /** * The database name associated with the user's credentials. * @@ -2821,6 +2821,20 @@ public interface MongoDbEndpointBuilderFactory { doSetProperty("collectionIndex", collectionIndex); return this; } + /** + * Set the whole Connection String/Uri for mongodb endpoint. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: common + * + * @param connectionUriString the value to set + * @return the dsl builder + */ + default MongoDbEndpointBuilder connectionUriString(String connectionUriString) { + doSetProperty("connectionUriString", connectionUriString); + return this; + } /** * Create collection during initialisation if it doesn't exist. Default * is true. @@ -2985,20 +2999,6 @@ public interface MongoDbEndpointBuilderFactory { doSetProperty("outputType", outputType); return this; } - /** - * Set the whole Connection String/Uri for mongodb endpoint. - * - * The option is a: <code>java.lang.String</code> type. - * - * Group: additional - * - * @param connectionUriString the value to set - * @return the dsl builder - */ - default MongoDbEndpointBuilder connectionUriString(String connectionUriString) { - doSetProperty("connectionUriString", connectionUriString); - return this; - } /** * The database name associated with the user's credentials. * diff --git a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/MongodbUriDsl.kt b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/MongodbUriDsl.kt index 86cfe78ca27..5083691a896 100644 --- a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/MongodbUriDsl.kt +++ b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/MongodbUriDsl.kt @@ -66,6 +66,13 @@ public class MongodbUriDsl( it.property("collectionIndex", collectionIndex) } + /** + * Set the whole Connection String/Uri for mongodb endpoint. + */ + public fun connectionUriString(connectionUriString: String) { + it.property("connectionUriString", connectionUriString) + } + /** * Create collection during initialisation if it doesn't exist. Default is true. */ @@ -196,13 +203,6 @@ public class MongodbUriDsl( it.property("lazyStartProducer", lazyStartProducer.toString()) } - /** - * Set the whole Connection String/Uri for mongodb endpoint. - */ - public fun connectionUriString(connectionUriString: String) { - it.property("connectionUriString", connectionUriString) - } - /** * Sets the logical name of the application. The application name may be used by the client to * identify the application to the server, for use in server logs, slow query logs, and profile