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

oscerd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git


The following commit(s) were added to refs/heads/main by this push:
     new bd575c62e chore: cassandra-sink takes the local datacenter (#3170) 
(#3195)
bd575c62e is described below

commit bd575c62ef3732f4fe338a40b797e9e935ea2eb3
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 18 15:11:26 2026 +0100

    chore: cassandra-sink takes the local datacenter (#3170) (#3195)
    
    cassandra-sink always used the cql component's default local datacenter,
    datacenter1, so a Cassandra cluster whose datacenter has another name could
    not be used: the route failed to start with "No node was available to
    execute the query".
    
    Add an optional datacenter option, mapped to the cql endpoint's datacenter
    parameter with an optional placeholder and no default, so the endpoint URI
    is unchanged when it is not set. The description, Good to know and the
    partial page say how to find the name of the datacenter, what happens when
    it does not match, and that the Kamelet connects without TLS.
    
    TLS is not added: the cql endpoint has no TLS option, only a CqlSession
    bean or the driver's own configuration (application.conf or
    datastax-java-driver.* JVM system properties) can turn it on.
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../ROOT/partials/cassandra-sink-description.adoc  | 24 ++++++++++++++++++++++
 kamelets/cassandra-sink.kamelet.yaml               |  9 ++++++--
 .../main/resources/META-INF/kamelets-index.json    |  2 +-
 .../resources/kamelets/cassandra-sink.kamelet.yaml |  9 ++++++--
 4 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/docs/modules/ROOT/partials/cassandra-sink-description.adoc 
b/docs/modules/ROOT/partials/cassandra-sink-description.adoc
index a7076ad23..ba3c592df 100644
--- a/docs/modules/ROOT/partials/cassandra-sink-description.adoc
+++ b/docs/modules/ROOT/partials/cassandra-sink-description.adoc
@@ -4,6 +4,30 @@
 
 The Kamelet supports username/password authentication.
 
+The Kamelet has no TLS option. It connects without TLS, so a cluster that 
accepts only TLS connections refuses it.
+
+=== The local datacenter
+
+The Kamelet connects to the nodes in `connectionHost` as members of one 
datacenter, the local datacenter, and runs the
+statements only on the nodes of that datacenter. It is `datacenter1` unless 
`datacenter` says otherwise, the name a
+Cassandra installed with its default settings uses. When the datacenter of the 
cluster has another name, set
+`datacenter` to it, or the Kamelet fails to start with `No node was available 
to execute the query` (with
+`prepareStatements` false, it starts and each message fails with that error 
instead).
+
+The name of the datacenter is on the `Datacenter:` line of `nodetool status`, 
or in the `data_center` column of
+`SELECT data_center FROM system.local` in `cqlsh`.
+
+For example, for a cluster whose datacenter is called `dc-east`:
+
+[source,yaml]
+----
+connectionHost: cassandra1.example.com,cassandra2.example.com
+connectionPort: 9042
+keyspace: customers
+datacenter: dc-east
+query: INSERT INTO accounts (id, username, city) VALUES (?, ?, ?)
+----
+
 === Payload
 
 With `jsonPayload` set to true, the default, the body must be a JSON array 
that holds the values of the `?` markers of
diff --git a/kamelets/cassandra-sink.kamelet.yaml 
b/kamelets/cassandra-sink.kamelet.yaml
index d4afe43c4..7f102791a 100644
--- a/kamelets/cassandra-sink.kamelet.yaml
+++ b/kamelets/cassandra-sink.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
 
       Output: the body afterwards is an empty List for an INSERT, UPDATE or 
DELETE.
 
-      Good to know: with `jsonPayload` true, the default, a message fails when 
its body is not a JSON array, such as a JSON object. The values are sent apart 
from the statement, so the content of a message cannot change it. `ANY`, the 
default `consistencyLevel`, is the weakest level: a write counts as done even 
before a replica has stored it.
+      Good to know: with `jsonPayload` true, the default, a message fails when 
its body is not a JSON array, such as a JSON object. The values are sent apart 
from the statement, so the content of a message cannot change it. `ANY`, the 
default `consistencyLevel`, is the weakest level: a write counts as done even 
before a replica has stored it. When the datacenter of the cluster is not 
called `datacenter1`, set `datacenter` to its name, or the Kamelet fails to 
start with `No node was avail [...]
     required:
       - connectionHost
       - connectionPort
@@ -57,6 +57,11 @@ spec:
         description: The port the Cassandra nodes listen on for CQL clients, 
the same for all hosts. Cassandra uses 9042 unless it was set up otherwise.
         type: string
         example: 9042
+      datacenter:
+        title: Local Datacenter
+        description: The name of the Cassandra datacenter that the nodes in 
`connectionHost` belong to, as the `Datacenter` line of `nodetool status` shows 
it. The Kamelet runs the statements only on the nodes of this datacenter. When 
it is not set, `datacenter1` is used, the name a Cassandra installed with its 
default settings uses. A name that does not match makes the Kamelet fail to 
start with `No node was available to execute the query`, or each message fail 
with it when `prepareStat [...]
+        type: string
+        example: dc-east
       keyspace:
         title: Keyspace 
         description: The keyspace (the Cassandra name for a database) that 
holds the tables of `query`.
@@ -130,4 +135,4 @@ spec:
         - removeHeader:
             name: CamelCqlQuery
         - to:
-            uri: 
"{{local-sql-cassandraql-sink}}://{{connectionHost}}:{{connectionPort}}/{{keyspace}}?username={{?username}}&password={{?password}}&prepareStatements={{prepareStatements}}&consistencyLevel={{consistencyLevel}}&cql=RAW({{query}})&extraTypeCodecs={{?extraTypeCodecs}}"
+            uri: 
"{{local-sql-cassandraql-sink}}://{{connectionHost}}:{{connectionPort}}/{{keyspace}}?username={{?username}}&password={{?password}}&datacenter={{?datacenter}}&prepareStatements={{prepareStatements}}&consistencyLevel={{consistencyLevel}}&cql=RAW({{query}})&extraTypeCodecs={{?extraTypeCodecs}}"
diff --git 
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json 
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index 6ef37a1e9..24cea83a9 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -505,7 +505,7 @@
     "supportLevel" : "Stable",
     "title" : "Cassandra Sink",
     "summary" : "Runs a CQL statement, such as an INSERT, in an Apache 
Cassandra keyspace for each message, with the values of its `?` markers taken 
from the JSON array in the body.",
-    "description" : "Runs a CQL statement, such as an INSERT, in an Apache 
Cassandra keyspace for each message, with the values of its `?` markers taken 
from the JSON array in the body.\n\nUse it to store events or records as rows 
of a Cassandra table, for example each reading of a sensor or each order that 
arrives on a Kafka topic.\n\nInput: the body is a JSON array, as text, with one 
value for each `?` in `query`, in the same order: for `INSERT INTO accounts 
(id, username, city) VALUES [...]
+    "description" : "Runs a CQL statement, such as an INSERT, in an Apache 
Cassandra keyspace for each message, with the values of its `?` markers taken 
from the JSON array in the body.\n\nUse it to store events or records as rows 
of a Cassandra table, for example each reading of a sensor or each order that 
arrives on a Kafka topic.\n\nInput: the body is a JSON array, as text, with one 
value for each `?` in `query`, in the same order: for `INSERT INTO accounts 
(id, username, city) VALUES [...]
     "group" : "Cassandra",
     "namespace" : "Nosql",
     "provider" : "Apache Software Foundation"
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/cassandra-sink.kamelet.yaml
 
b/library/camel-kamelets/src/main/resources/kamelets/cassandra-sink.kamelet.yaml
index d4afe43c4..7f102791a 100644
--- 
a/library/camel-kamelets/src/main/resources/kamelets/cassandra-sink.kamelet.yaml
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/cassandra-sink.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
 
       Output: the body afterwards is an empty List for an INSERT, UPDATE or 
DELETE.
 
-      Good to know: with `jsonPayload` true, the default, a message fails when 
its body is not a JSON array, such as a JSON object. The values are sent apart 
from the statement, so the content of a message cannot change it. `ANY`, the 
default `consistencyLevel`, is the weakest level: a write counts as done even 
before a replica has stored it.
+      Good to know: with `jsonPayload` true, the default, a message fails when 
its body is not a JSON array, such as a JSON object. The values are sent apart 
from the statement, so the content of a message cannot change it. `ANY`, the 
default `consistencyLevel`, is the weakest level: a write counts as done even 
before a replica has stored it. When the datacenter of the cluster is not 
called `datacenter1`, set `datacenter` to its name, or the Kamelet fails to 
start with `No node was avail [...]
     required:
       - connectionHost
       - connectionPort
@@ -57,6 +57,11 @@ spec:
         description: The port the Cassandra nodes listen on for CQL clients, 
the same for all hosts. Cassandra uses 9042 unless it was set up otherwise.
         type: string
         example: 9042
+      datacenter:
+        title: Local Datacenter
+        description: The name of the Cassandra datacenter that the nodes in 
`connectionHost` belong to, as the `Datacenter` line of `nodetool status` shows 
it. The Kamelet runs the statements only on the nodes of this datacenter. When 
it is not set, `datacenter1` is used, the name a Cassandra installed with its 
default settings uses. A name that does not match makes the Kamelet fail to 
start with `No node was available to execute the query`, or each message fail 
with it when `prepareStat [...]
+        type: string
+        example: dc-east
       keyspace:
         title: Keyspace 
         description: The keyspace (the Cassandra name for a database) that 
holds the tables of `query`.
@@ -130,4 +135,4 @@ spec:
         - removeHeader:
             name: CamelCqlQuery
         - to:
-            uri: 
"{{local-sql-cassandraql-sink}}://{{connectionHost}}:{{connectionPort}}/{{keyspace}}?username={{?username}}&password={{?password}}&prepareStatements={{prepareStatements}}&consistencyLevel={{consistencyLevel}}&cql=RAW({{query}})&extraTypeCodecs={{?extraTypeCodecs}}"
+            uri: 
"{{local-sql-cassandraql-sink}}://{{connectionHost}}:{{connectionPort}}/{{keyspace}}?username={{?username}}&password={{?password}}&datacenter={{?datacenter}}&prepareStatements={{prepareStatements}}&consistencyLevel={{consistencyLevel}}&cql=RAW({{query}})&extraTypeCodecs={{?extraTypeCodecs}}"

Reply via email to