0

I am using Vertx Redis client from the package io.vertx.rxjava.redis.RedisClient to connect to Elasticache Redis.

It does connect but shows an error,

io.vertx.redis.client.impl.types.ErrorType: MOVED 4985 xxx.xxx.xxx.xxx:63791

After reading about the error I found its because there are sharding and its not able to connect to all of them.

From the library, I am not able to figure what method to use to connect in cluster mode.

mux032
  • 65
  • 2
  • 8

1 Answers1

0

Here is an example how to connect and send get command in cluster mode.

Define options:

final RedisOptions options = new RedisOptions()
    .setType(RedisClientType.CLUSTER)
    .setUseSlave(RedisSlaves.SHARE)
    .setMaxWaitingHandlers(128 * 1024)
    .addEndpoint("redis://127.0.0.1:7000")
    .addEndpoint("redis://127.0.0.1:7001")
    .addEndpoint("redis://127.0.0.1:7002")
    .addEndpoint("redis://127.0.0.1:7003")
    .addEndpoint("redis://127.0.0.1:7004")
    .addEndpoint("redis://127.0.0.1:7005");

Connect and send command:

Redis.createClient(vertx, options).connect(onCreate -> {
  final Redis cluster = onCreate.result();
  cluster.send(cmd(SET).arg("key"), set -> {
    System.out.println(set.result());
  });
});

Tip: If you are unsure how use some library or documentation is not clear enough you can always checkout Tests if that projects has them. You can check how they are implemented so you can use examples from there.

Pendula
  • 688
  • 6
  • 17
  • There are two Redis clients in Vertx and I require rxjava one which is present in the package `io.vertx.rxjava.redis.RedisClient`. It does have cluster related operations like, clusterAddslots, clusterCountFailureReports and more, but what it does not have is a way to connect in cluster mode. The client you are using does provide Redis in cluster mode but it's not rxjava. – mux032 Aug 02 '19 at 16:32
  • Which version of vert.x are you using? – Pendula Aug 02 '19 at 17:14