Skip to content

Commit 73354b0

Browse files
DOC-5716 Lettuce SCE connection details
1 parent 6d22eed commit 73354b0

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

content/develop/clients/lettuce/connect.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,47 @@ public class Pool {
254254
```
255255

256256
In this setup, `LettuceConnectionFactory` is a custom class you would need to implement, adhering to Apache Commons Pool's `PooledObjectFactory` interface, to manage lifecycle events of pooled `StatefulRedisConnection` objects.
257+
258+
## Connect using Seamless client experience (SCE)
259+
260+
*Seamless client experience (SCE)* is a feature of Redis Cloud and
261+
Redis Enterprise servers that lets them actively notify clients
262+
about planned server maintenance shortly before it happens. This
263+
lets a client take action to avoid disruptions in service.
264+
See [Seamless client experience]({{< relref "/develop/clients/sce" >}})
265+
for more information about SCE.
266+
267+
To enable SCE on the client, create a `MaintenanceEventsOptions` object
268+
and pass it to the `ClientOptions` builder using the `supportMaintenanceEvents()` method:
269+
270+
```java
271+
import io.lettuce.core.*;
272+
import io.lettuce.core.api.StatefulRedisConnection;
273+
import io.lettuce.core.protocol.ProtocolVersion;
274+
.
275+
.
276+
277+
RedisClient redisClient = RedisClient.create("redis://localhost:6379");
278+
279+
MaintenanceEventsOptions maintOptions = MaintenanceEventsOptions.builder()
280+
// You can also pass `false` as a parameter to `supportMaintenanceEvents()`
281+
// to explicitly disable SCE.
282+
.supportMaintenanceEvents()
283+
.build();
284+
285+
ClientOptions clientOptions = ClientOptions.builder()
286+
.supportMaintenanceEvents(maintOptions)
287+
.protocolVersion(ProtocolVersion.RESP3)
288+
.build();
289+
290+
redisClient.setOptions(clientOptions);
291+
292+
try (StatefulRedisConnection<String, String> connection = redisClient.connect()) {
293+
.
294+
.
295+
```
296+
297+
{{< note >}}SCE requires the [RESP3]({{< relref "/develop/reference/protocol-spec#resp-versions" >}})
298+
protocol, so you must add the option `protocolVersion(ProtocolVersion.RESP3)`
299+
to the `ClientOptions` builder explicitly.
300+
{{< /note >}}

0 commit comments

Comments
 (0)