Redis Sink
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
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.
Use 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.
Input: the body is the value, as text. The key header (or ce-key) gives the key, for commands that work on a key such as SET, GET or RPUSH. The channel header (or ce-channel) gives the channel for PUBLISH; without it, the channel in channels is used.
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. 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. Headers that start with CamelRedis are removed from the message first, so they cannot change what the Kamelet does.
Configuration Options
The following table summarizes the configuration options available for the redis-sink Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Command | Required The Redis command to run for each message, such as | string | GET | SET | |
Redis Host | Required The host name or IP address of the Redis server. | string | redis.example.com | ||
Redis Port | Required The port of the Redis server, usually 6379. | integer | 6379 | ||
Channels | The channel that | string | one | ||
Database | 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. | integer | 0 | 1 | |
Password | The password to log in to Redis with, the one set with | string | |||
Serializer | The full Java class name of the Spring Data Redis serializer that turns the values and keys into the bytes Redis stores. The default stores them as text. | string | org.springframework.data.redis.serializer.StringRedisSerializer | ||
Use TLS | Whether to connect with TLS (SSL), for a Redis server that offers TLS on | boolean | false | ||
Username | 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 | string |
Dependencies
At runtime, the redis-sink Kamelet relies upon the presence of the following dependencies:
-
camel:kamelet
-
camel:spring-redis
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:timer-source"
parameters:
period: 10000
message: 'test'
steps:
- to:
uri: "kamelet:redis-sink" You can now run it directly through the following command
camel run route.yaml Redis Sink Kamelet Description
In-Memory Data Store
This Kamelet integrates with Redis, an open-source, in-memory data structure store used as a database, cache, and message broker. Redis provides high performance and low latency data operations.
Data Structures
Redis supports various data structures including:
-
Strings and binary-safe strings
-
Lists, sets, and sorted sets
-
Hashes and bitmaps
-
HyperLogLogs and streams
Caching and Session Storage
Commonly used for caching frequently accessed data and session storage in web applications, providing fast data retrieval and improved application performance.
Persistence Options
Redis offers configurable persistence options including:
-
RDB snapshots for point-in-time backups
-
AOF (Append Only File) for durability
-
Hybrid persistence combining both approaches