3.7.0之后带有事件总线消费者的PubSub vertx redis

3.7.0之后带有事件总线消费者的PubSub vertx redis,redis,vert.x,Redis,Vert.x,我们正在将Vertx代码库从3.6.3迁移到3.8.1 我不确定redis pub/sub和事件总线消费者是否仍在一起工作。我在新版本中也找不到任何文档 从 vertx.eventBus().consumer(“io.vertx.redis.channel1”),已收到->{ //对你的信息做任何你需要做的事情 JsonObject value=received.body().getJsonObject(“value”); //该值是具有以下属性的JSON文档 //通道-将此消息发送到的通道 /

我们正在将Vertx代码库从3.6.3迁移到3.8.1

我不确定redis pub/sub和事件总线消费者是否仍在一起工作。我在新版本中也找不到任何文档

vertx.eventBus().consumer(“io.vertx.redis.channel1”),已收到->{
//对你的信息做任何你需要做的事情
JsonObject value=received.body().getJsonObject(“value”);
//该值是具有以下属性的JSON文档
//通道-将此消息发送到的通道
//模式-如果使用PSUSCRIBE命令,则存在模式,并且是与此消息通道匹配的模式
//消息-消息有效负载
});
RedisClient redis=RedisClient.create(vertx,newredisoptions());
redis.subscribe(“channel1”,res->{
如果(res.successed()){
//所以有些事。。。
}
});
现在如何使用新的Redis客户端/RedisAPI


这不是很具有描述性。(没有subscribe命令..也没有channel1的跟踪)

您应该能够为订阅io.vertx.redis.client.redis#handler注册一个处理程序。将使用io.vertx.redis.client.Response引用(带有相应信息)调用已发布消息。

您应该能够注册订阅io.vertx.redis.client.redis处理程序。将使用io.vertx.redis.client.Response引用(带有相应的信息)调用发布的消息。

欢迎使用SO,请提供示例代码以说明如何执行此操作。它提高了您的答案质量,让您的答案更容易理解。欢迎使用SO,请提供示例代码以说明应该如何操作。它提高了你的答案质量,让你的答案更容易理解。
vertx.eventBus().<JsonObject>consumer("io.vertx.redis.channel1", received -> {
  // do whatever you need to do with your message
  JsonObject value = received.body().getJsonObject("value");
  // the value is a JSON doc with the following properties
  // channel - The channel to which this message was sent
  // pattern - Pattern is present if you use psubscribe command and is the pattern that matched this message channel
  // message - The message payload
});

RedisClient redis = RedisClient.create(vertx, new RedisOptions());

redis.subscribe("channel1", res -> {
  if (res.succeeded()) {
    // so something...
  }
});