|
| 1 | += Redis Flink Connector |
| 2 | +:linkattrs: |
| 3 | +:name: Redis Flink Connector |
| 4 | +:project-owner: redis-field-engineering |
| 5 | +:project-name: redis-flink-connector |
| 6 | +:project-group: com.redis |
| 7 | +:project-version: 0.0.1 |
| 8 | +:dist-repo-name: redis-flink-connector-dist |
| 9 | + |
| 10 | +The Redis Flink Connector is a highly performant, scalable Flink Source and Sink |
| 11 | +connector for Redis. It is designed and built to provide a simple, scalable means of |
| 12 | +using Redis as a source and Sink for your stream-processing use cases in Flink. |
| 13 | + |
| 14 | +== Partitioned Streams |
| 15 | + |
| 16 | +The Redis Flink Connector supports partitioned streams, allowing you to configure how many |
| 17 | +separate partitions you want for your stream of data. This allows you to scale your stream |
| 18 | +across a Redis Cluster, allowing Flink to manage the work of coordinating which consumer |
| 19 | +owns which stream. |
| 20 | + |
| 21 | +== Exactly-Once Semantics |
| 22 | + |
| 23 | +The Redis Flink Connector supports exactly-once semantics. This is tied into |
| 24 | +the checkpointing mechanism in Flink. Please note that "exactly once" refers to |
| 25 | +is at the checkpoint level, so in the case of a failure in your pipeline |
| 26 | +you may see messages within a checkpoint being delivered more than once |
| 27 | + |
| 28 | +=== Gradle |
| 29 | + |
| 30 | +Add the following to your `build.gradle` file |
| 31 | + |
| 32 | +[source,groovy] |
| 33 | +[subs="attributes"] |
| 34 | +.build.gradle |
| 35 | +---- |
| 36 | +dependencies { |
| 37 | + implementation '{project-group}:{project-name}-spring:{project-version}' |
| 38 | +} |
| 39 | +---- |
| 40 | + |
| 41 | + |
| 42 | +== Using the Stream Source |
| 43 | + |
| 44 | +To use the Flink stream source, you can create a `RedisSourceConfig`. |
| 45 | + |
| 46 | +The configuration options are as follows: |
| 47 | + |
| 48 | +The following table describes the fields in that class: |
| 49 | + |
| 50 | +[cols="1,1,1,1",options="header"] |
| 51 | +|=== |
| 52 | +| **Field** | **Type** | **Default Value** | **Required** |
| 53 | +| `host` | `String` | `"localhost"` | No |
| 54 | +| `port` | `int` | `6379` | No |
| 55 | +| `password` | `String` | `""` (empty string) | No |
| 56 | +| `user` | `String` | `"default"` | No |
| 57 | +| `consumerGroup` | `String` | N/A | Yes |
| 58 | +| `topicName` | `String` | N/A | Yes |
| 59 | +| `numPartitions` | `int` | N/A | Yes |
| 60 | +| `useClusterApi` | `boolean` | `false` | No |
| 61 | +| `requireAck` | `boolean` | `true` | No |
| 62 | +| `startingId` | `StreamEntryID` | `StreamEntryID.XGROUP_LAST_ENTRY` | No |
| 63 | +|=== |
| 64 | + |
| 65 | +You can then initialize the Source Builder using: |
| 66 | + |
| 67 | +[source,java] |
| 68 | +---- |
| 69 | +RedisSourceBuilder<RedisMessage> sourceBuilder = new RedisSourceBuilder<>(sourceConfig, new RedisMessageDeserializer()); |
| 70 | +---- |
| 71 | + |
| 72 | +After that, all that's left is to use your environment to add the source to your pipeline: |
| 73 | + |
| 74 | +[source,java] |
| 75 | +---- |
| 76 | +final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); |
| 77 | +env.getConfig().setGlobalJobParameters(globalConfig); |
| 78 | +env.enableCheckpointing(5000); |
| 79 | +env.setParallelism(4); |
| 80 | +TypeInformation<RedisMessage> typeInfo = TypeInformation.of(RedisMessage.class); |
| 81 | +String sourceName = "Redis to Redis"; |
| 82 | +env.fromSource(sourceBuilder.build(), WatermarkStrategy.noWatermarks(), sourceName, typeInfo).sinkTo(sinkBuilder.build()); |
| 83 | +---- |
| 84 | + |
| 85 | +== Using the Redis Stream Sink |
| 86 | + |
| 87 | +To use the Redis Stream Sink, you can initialize a `RedisSinkConfig` object with the following: |
| 88 | + |
| 89 | +The following table describes the fields in that class: |
| 90 | + |
| 91 | +[cols="1,1,1,1",options="header"] |
| 92 | +|=== |
| 93 | +| **Field** | **Type** | **Default Value** | **Required** |
| 94 | +| `host` | `String` | `"localhost"` | No |
| 95 | +| `port` | `int` | `6379` | No |
| 96 | +| `password` | `String` | `""` (empty string) | No |
| 97 | +| `user` | `String` | `"default"` | No |
| 98 | +| `topicName` | `String` | N/A | Yes |
| 99 | +| `numPartitions` | `int` | N/A | Yes |
| 100 | +|=== |
| 101 | + |
| 102 | +You then have to initialize the builder and sink to it: |
| 103 | + |
| 104 | +[source,java] |
| 105 | +---- |
| 106 | +RedisSinkBuilder<RedisMessage> sinkBuilder = new RedisSinkBuilder<>(new RedisPassthroughSerializer(), sinkConfig); |
| 107 | +final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); |
| 108 | +env.getConfig().setGlobalJobParameters(globalConfig); |
| 109 | +env.enableCheckpointing(5000); |
| 110 | +env.setParallelism(4); |
| 111 | +TypeInformation<RedisMessage> typeInfo = TypeInformation.of(RedisMessage.class); |
| 112 | +String sourceName = "Redis to Redis"; |
| 113 | +env.fromSource(sourceBuilder.build(), WatermarkStrategy.noWatermarks(), sourceName, typeInfo).sinkTo(sinkBuilder.build()); |
| 114 | +---- |
| 115 | + |
| 116 | +== Quick Start |
| 117 | + |
| 118 | +You can run the demo in this repo by running: |
| 119 | + |
| 120 | +[source,bash] |
| 121 | +---- |
| 122 | +docker compose up -d |
| 123 | +./example-redis-job.sh |
| 124 | +---- |
| 125 | + |
| 126 | +This will spin up Redis, a Flink Job Manager and Task Manager, and start a Job with Redis as the Source and Sink. |
| 127 | + |
| 128 | + |
| 129 | +== Support |
| 130 | + |
| 131 | +{name} is supported by Redis, Inc. for enterprise-tier customers as a 'Developer Tool' under the https://redis.io/legal/software-support-policy/[Redis Software Support Policy.] For non enterprise-tier customers we supply support for {name} on a good-faith basis. |
| 132 | +To report bugs, request features, or receive assistance, please https://github.com/{project-owner}/{dist-repo-name}/issues[file an issue]. |
| 133 | + |
| 134 | +== License |
| 135 | + |
| 136 | +{name} is licensed under the Business Source License 1.1. Copyright (C) 2024 Redis, Inc. See link:LICENSE.md[LICENSE] for details. |
0 commit comments