This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 64870db40 chore: redis-sink and redis-source can log in to Redis and
use TLS (#3170) (#3177)
64870db40 is described below
commit 64870db409efd73ac944eb827d3323474c6dd388
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 18 10:31:07 2026 +0100
chore: redis-sink and redis-source can log in to Redis and use TLS (#3170)
(#3177)
* chore: redis-sink and redis-source can log in to Redis (#3170)
Both Kamelets now pass the spring-redis component a Jedis connection
factory built from the Kamelet options, which adds the optional
`username` (ACL user), `password` and `ssl` (TLS, default false)
options, and `database` (default 0) on the sink. The serializer
still applies. With the new options unset the connection is the same
as the one the component built before: host and port only, no
password, no TLS, database 0.
Jedis and Spring Data Redis already come with camel-spring-redis, so
no dependency is added. The password and TLS use the
JedisConnectionFactory setters, as RedisStandaloneConfiguration takes
the password only as a RedisPassword object.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* chore: redis-source page: a placeholder name that AsciiDoc does not read
as an attribute (#3170)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../ROOT/partials/redis-source-description.adoc | 22 +++++++++++-
kamelets/redis-sink.kamelet.yaml | 39 +++++++++++++++++++++-
kamelets/redis-source.kamelet.yaml | 32 +++++++++++++++++-
.../main/resources/META-INF/kamelets-index.json | 4 +--
.../resources/kamelets/redis-sink.kamelet.yaml | 39 +++++++++++++++++++++-
.../resources/kamelets/redis-source.kamelet.yaml | 32 +++++++++++++++++-
6 files changed, 161 insertions(+), 7 deletions(-)
diff --git a/docs/modules/ROOT/partials/redis-source-description.adoc
b/docs/modules/ROOT/partials/redis-source-description.adoc
index 72cda0f92..c5f60e40f 100644
--- a/docs/modules/ROOT/partials/redis-source-description.adoc
+++ b/docs/modules/ROOT/partials/redis-source-description.adoc
@@ -2,7 +2,7 @@
=== Authentication
-This Kamelet connects to Redis without a password and without TLS. It has no
option for authentication, so the Redis server must accept connections without
a password.
+By default this Kamelet connects to Redis without a password and without TLS.
For a Redis server that asks for a login, set `password`: the password set with
`requirepass`, or, with `username`, the password of an ACL user. For a Redis
server that needs TLS, set `ssl` to true; the certificate of the server must
then be trusted by Java and name `redisHost`.
=== Configuration
@@ -12,6 +12,8 @@ The Redis Source Kamelet supports the following
configurations:
- **Redis Port**: The port number of the Redis server, usually 6379 (required)
- **Channels**: Redis channels to subscribe to, separated by commas (required)
- **Command**: `SUBSCRIBE` (the default) for channel names, or `PSUBSCRIBE`
for channel patterns
+- **Username** and **Password**: the login, for a Redis server that asks for
one
+- **Use TLS**: whether to connect with TLS, false by default
=== Output Format
@@ -49,6 +51,24 @@ The Kamelet outputs the messages received from the
subscribed channels. The body
uri: "kamelet:log-sink"
----
+=== Example with a Password and TLS
+
+[source,yaml,subs='+attributes,macros']
+----
+- route:
+ from:
+ uri: "kamelet:redis-source"
+ parameters:
+ redisHost: "redis.example.com"
+ redisPort: "6379"
+ password: "{{redis.password}}"
+ ssl: true
+ channels: "notifications"
+ steps:
+ - to:
+ uri: "kamelet:log-sink"
+----
+
=== Example with a Channel Pattern
[source,yaml,subs='+attributes,macros']
diff --git a/kamelets/redis-sink.kamelet.yaml b/kamelets/redis-sink.kamelet.yaml
index 1fc2b8c7e..8fdca8856 100644
--- a/kamelets/redis-sink.kamelet.yaml
+++ b/kamelets/redis-sink.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
Output: when it is used inside a route, the body afterwards is what
Redis answered, such as the value for `GET` or the new length of the list for
`RPUSH`; for `SET` the body is unchanged.
- Good to know: the default `command` is `GET`, which reads and stores
nothing, so set it to the command you need. A body that is not text, such as a
Map, fails the message; turn it into JSON text first, for example with
`json-serialize-action`. It connects with no password and no TLS.
+ Good to know: the default `command` is `GET`, which reads and stores
nothing, so set it to the command you need. A body that is not text, such as a
Map, fails the message; turn it into JSON text first, for example with
`json-serialize-action`. By default it connects with no password and no TLS, to
database 0: set `password` (and `username` for an ACL user) for a Redis server
that asks for a login, and `ssl` for one that needs TLS.
required:
- redisHost
- redisPort
@@ -56,6 +56,30 @@ spec:
description: The port of the Redis server, usually 6379.
type: integer
example: 6379
+ username:
+ title: Username
+ description: The Redis user to log in as, for a Redis server with
access control lists (ACL, Redis 6 and later). Leave it empty to log in with
`password` alone, as the `default` user.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ password:
+ title: Password
+ description: The password to log in to Redis with, the one set with
`requirepass` or the password of the user in `username`. Leave it empty for a
Redis server that does not ask for a password.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ database:
+ title: Database
+ description: The number of the Redis database to use, from 0 to 15 on
a Redis server with the default settings. The commands run on this database.
+ type: integer
+ default: 0
+ example: 1
+ ssl:
+ title: Use TLS
+ description: "Whether to connect with TLS (SSL), for a Redis server
that offers TLS on `redisPort`. The certificate of the server is checked: it
must be trusted by Java, as one from a public certificate authority is, and
name `redisHost`."
+ type: boolean
+ default: false
command:
title: Command
description: The Redis command to run for each message, such as `SET`
to store the body under the key, `RPUSH` or `LPUSH` to add it to a list, `SADD`
to add it to a set, or `PUBLISH` to send it on a channel.
@@ -95,6 +119,18 @@ spec:
- "camel:kamelet"
- "camel:spring-redis"
template:
+ beans:
+ - name: redisConnectionFactory
+ type:
"#class:org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
+ initMethod: afterPropertiesSet
+ destroyMethod: destroy
+ properties:
+ standaloneConfiguration.hostName: "{{redisHost}}"
+ standaloneConfiguration.port: "{{redisPort}}"
+ standaloneConfiguration.database: "{{database}}"
+ standaloneConfiguration.username: "{{?username}}"
+ password: "{{?password}}"
+ useSsl: "{{ssl}}"
from:
uri: kamelet:source
steps:
@@ -165,3 +201,4 @@ spec:
channels: "{{channels}}"
command: "{{command}}"
serializer: "#class:{{serializer}}"
+ connectionFactory: "#bean:{{redisConnectionFactory}}"
diff --git a/kamelets/redis-source.kamelet.yaml
b/kamelets/redis-source.kamelet.yaml
index 929d93327..56074ba48 100644
--- a/kamelets/redis-source.kamelet.yaml
+++ b/kamelets/redis-source.kamelet.yaml
@@ -37,7 +37,7 @@ spec:
Output: the body is the published message, as text. The
`CamelRedis.Channel` header is the channel it was published on.
- Good to know: only the messages published while the integration runs are
received; Redis does not keep them for later. It connects with no password and
no TLS.
+ Good to know: only the messages published while the integration runs are
received; Redis does not keep them for later. By default it connects with no
password and no TLS: set `password` (and `username` for an ACL user) for a
Redis server that asks for a login, and `ssl` for one that needs TLS. The
channels are shared by all the databases of a Redis server, so there is no
database to choose.
required:
- redisHost
- redisPort
@@ -54,6 +54,24 @@ spec:
description: The port of the Redis server, usually 6379.
type: integer
example: 6379
+ username:
+ title: Username
+ description: The Redis user to log in as, for a Redis server with
access control lists (ACL, Redis 6 and later). Leave it empty to log in with
`password` alone, as the `default` user.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ password:
+ title: Password
+ description: The password to log in to Redis with, the one set with
`requirepass` or the password of the user in `username`. Leave it empty for a
Redis server that does not ask for a password.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ ssl:
+ title: Use TLS
+ description: "Whether to connect with TLS (SSL), for a Redis server
that offers TLS on `redisPort`. The certificate of the server is checked: it
must be trusted by Java, as one from a public certificate authority is, and
name `redisHost`."
+ type: boolean
+ default: false
command:
title: Command
description: How to subscribe. `SUBSCRIBE` listens to the channels
named in `channels`; `PSUBSCRIBE` treats them as patterns, such as `orders.*`,
and listens to every channel that matches.
@@ -82,6 +100,17 @@ spec:
- "camel:kamelet"
- "camel:spring-redis"
template:
+ beans:
+ - name: redisConnectionFactory
+ type:
"#class:org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
+ initMethod: afterPropertiesSet
+ destroyMethod: destroy
+ properties:
+ standaloneConfiguration.hostName: "{{redisHost}}"
+ standaloneConfiguration.port: "{{redisPort}}"
+ standaloneConfiguration.username: "{{?username}}"
+ password: "{{?password}}"
+ useSsl: "{{ssl}}"
from:
uri: spring-redis
parameters:
@@ -90,6 +119,7 @@ spec:
channels: "{{channels}}"
command: "{{command}}"
serializer: "#class:{{serializer}}"
+ connectionFactory: "#bean:{{redisConnectionFactory}}"
steps:
- to:
uri: kamelet:sink
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 0cddeadca..51a0778ef 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
@@ -1875,7 +1875,7 @@
"supportLevel" : "Stable",
"title" : "Redis Sink",
"summary" : "Runs a Redis command for each message, such as storing the
body under a key with `SET`, adding it to a list with `RPUSH`, or publishing it
on a channel with `PUBLISH`.",
- "description" : "Runs a Redis command for each message, such as storing
the body under a key with `SET`, adding it to a list with `RPUSH`, or
publishing it on a channel with `PUBLISH`.\n\nUse it to put values in a Redis
cache for other applications to read, to push work items onto a Redis list, or
to publish events on a Redis channel that `redis-source` or other subscribers
listen to.\n\nInput: the body is the value, as text. The `key` header (or
`ce-key`) gives the key, for commands [...]
+ "description" : "Runs a Redis command for each message, such as storing
the body under a key with `SET`, adding it to a list with `RPUSH`, or
publishing it on a channel with `PUBLISH`.\n\nUse it to put values in a Redis
cache for other applications to read, to push work items onto a Redis list, or
to publish events on a Redis channel that `redis-source` or other subscribers
listen to.\n\nInput: the body is the value, as text. The `key` header (or
`ce-key`) gives the key, for commands [...]
"group" : "Redis",
"namespace" : "Cache",
"provider" : "Apache Software Foundation"
@@ -1885,7 +1885,7 @@
"supportLevel" : "Stable",
"title" : "Redis Source",
"summary" : "Receives the messages published on one or more Redis
channels, one message per publication, as a subscriber of Redis publish and
subscribe.",
- "description" : "Receives the messages published on one or more Redis
channels, one message per publication, as a subscriber of Redis publish and
subscribe.\n\nUse it to react to events that other applications publish on
Redis, such as notifications, cache invalidations or status changes. To publish
on a channel, use `redis-sink` with the `PUBLISH` command.\n\nOutput: the body
is the published message, as text. The `CamelRedis.Channel` header is the
channel it was published on.\n\nGo [...]
+ "description" : "Receives the messages published on one or more Redis
channels, one message per publication, as a subscriber of Redis publish and
subscribe.\n\nUse it to react to events that other applications publish on
Redis, such as notifications, cache invalidations or status changes. To publish
on a channel, use `redis-sink` with the `PUBLISH` command.\n\nOutput: the body
is the published message, as text. The `CamelRedis.Channel` header is the
channel it was published on.\n\nGo [...]
"group" : "Redis",
"namespace" : "Cache",
"provider" : "Apache Software Foundation"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/redis-sink.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/redis-sink.kamelet.yaml
index 1fc2b8c7e..8fdca8856 100644
--- a/library/camel-kamelets/src/main/resources/kamelets/redis-sink.kamelet.yaml
+++ b/library/camel-kamelets/src/main/resources/kamelets/redis-sink.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
Output: when it is used inside a route, the body afterwards is what
Redis answered, such as the value for `GET` or the new length of the list for
`RPUSH`; for `SET` the body is unchanged.
- Good to know: the default `command` is `GET`, which reads and stores
nothing, so set it to the command you need. A body that is not text, such as a
Map, fails the message; turn it into JSON text first, for example with
`json-serialize-action`. It connects with no password and no TLS.
+ Good to know: the default `command` is `GET`, which reads and stores
nothing, so set it to the command you need. A body that is not text, such as a
Map, fails the message; turn it into JSON text first, for example with
`json-serialize-action`. By default it connects with no password and no TLS, to
database 0: set `password` (and `username` for an ACL user) for a Redis server
that asks for a login, and `ssl` for one that needs TLS.
required:
- redisHost
- redisPort
@@ -56,6 +56,30 @@ spec:
description: The port of the Redis server, usually 6379.
type: integer
example: 6379
+ username:
+ title: Username
+ description: The Redis user to log in as, for a Redis server with
access control lists (ACL, Redis 6 and later). Leave it empty to log in with
`password` alone, as the `default` user.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ password:
+ title: Password
+ description: The password to log in to Redis with, the one set with
`requirepass` or the password of the user in `username`. Leave it empty for a
Redis server that does not ask for a password.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ database:
+ title: Database
+ description: The number of the Redis database to use, from 0 to 15 on
a Redis server with the default settings. The commands run on this database.
+ type: integer
+ default: 0
+ example: 1
+ ssl:
+ title: Use TLS
+ description: "Whether to connect with TLS (SSL), for a Redis server
that offers TLS on `redisPort`. The certificate of the server is checked: it
must be trusted by Java, as one from a public certificate authority is, and
name `redisHost`."
+ type: boolean
+ default: false
command:
title: Command
description: The Redis command to run for each message, such as `SET`
to store the body under the key, `RPUSH` or `LPUSH` to add it to a list, `SADD`
to add it to a set, or `PUBLISH` to send it on a channel.
@@ -95,6 +119,18 @@ spec:
- "camel:kamelet"
- "camel:spring-redis"
template:
+ beans:
+ - name: redisConnectionFactory
+ type:
"#class:org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
+ initMethod: afterPropertiesSet
+ destroyMethod: destroy
+ properties:
+ standaloneConfiguration.hostName: "{{redisHost}}"
+ standaloneConfiguration.port: "{{redisPort}}"
+ standaloneConfiguration.database: "{{database}}"
+ standaloneConfiguration.username: "{{?username}}"
+ password: "{{?password}}"
+ useSsl: "{{ssl}}"
from:
uri: kamelet:source
steps:
@@ -165,3 +201,4 @@ spec:
channels: "{{channels}}"
command: "{{command}}"
serializer: "#class:{{serializer}}"
+ connectionFactory: "#bean:{{redisConnectionFactory}}"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/redis-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/redis-source.kamelet.yaml
index 929d93327..56074ba48 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/redis-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/redis-source.kamelet.yaml
@@ -37,7 +37,7 @@ spec:
Output: the body is the published message, as text. The
`CamelRedis.Channel` header is the channel it was published on.
- Good to know: only the messages published while the integration runs are
received; Redis does not keep them for later. It connects with no password and
no TLS.
+ Good to know: only the messages published while the integration runs are
received; Redis does not keep them for later. By default it connects with no
password and no TLS: set `password` (and `username` for an ACL user) for a
Redis server that asks for a login, and `ssl` for one that needs TLS. The
channels are shared by all the databases of a Redis server, so there is no
database to choose.
required:
- redisHost
- redisPort
@@ -54,6 +54,24 @@ spec:
description: The port of the Redis server, usually 6379.
type: integer
example: 6379
+ username:
+ title: Username
+ description: The Redis user to log in as, for a Redis server with
access control lists (ACL, Redis 6 and later). Leave it empty to log in with
`password` alone, as the `default` user.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ password:
+ title: Password
+ description: The password to log in to Redis with, the one set with
`requirepass` or the password of the user in `username`. Leave it empty for a
Redis server that does not ask for a password.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ ssl:
+ title: Use TLS
+ description: "Whether to connect with TLS (SSL), for a Redis server
that offers TLS on `redisPort`. The certificate of the server is checked: it
must be trusted by Java, as one from a public certificate authority is, and
name `redisHost`."
+ type: boolean
+ default: false
command:
title: Command
description: How to subscribe. `SUBSCRIBE` listens to the channels
named in `channels`; `PSUBSCRIBE` treats them as patterns, such as `orders.*`,
and listens to every channel that matches.
@@ -82,6 +100,17 @@ spec:
- "camel:kamelet"
- "camel:spring-redis"
template:
+ beans:
+ - name: redisConnectionFactory
+ type:
"#class:org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
+ initMethod: afterPropertiesSet
+ destroyMethod: destroy
+ properties:
+ standaloneConfiguration.hostName: "{{redisHost}}"
+ standaloneConfiguration.port: "{{redisPort}}"
+ standaloneConfiguration.username: "{{?username}}"
+ password: "{{?password}}"
+ useSsl: "{{ssl}}"
from:
uri: spring-redis
parameters:
@@ -90,6 +119,7 @@ spec:
channels: "{{channels}}"
command: "{{command}}"
serializer: "#class:{{serializer}}"
+ connectionFactory: "#bean:{{redisConnectionFactory}}"
steps:
- to:
uri: kamelet:sink