2016-08-11 38 views
0

我想使用Redis的发布 - 订阅香奈儿顶点如下,但我不断收到Redis的身份验证的PubSub在vertx

NOAUTH需要验证

下面是一个示例代码片段:我已经配置的Redis redis.conf中的密码

vertx.eventBus().<JsonObject>consumer(VERTX_EVENTBUS_PREFIX + ASYNC_RESPONSE_CHANNEL, message -> { 

    log.debug("Vertx event bus consumer invoked");   
    }); 
}).exceptionHandler(t -> { 
    log.error("Exception thrown from vertx event bus consumer", t); 
}); 

// Subscribe to the redis async response channel 
redis.subscribe(ASYNC_RESPONSE_CHANNEL, res -> { 
    if (res.failed()) { 
     log.error("Failed to subscribe to the async response channel. " + res.cause().getMessage()); 
    } 
    if(res.succeeded()) { 
     log.debug("Subscribed to channel"); 
    } 
}).auth("redispasswd", null); 
+0

我找到了解决方案。我应该以不同的方式通过信条。我将编辑该问题以添加答案。 – Tharanga

回答

0

在订阅时设置auth是错误的。它需要在RedisOptions对象中设置,并且需要在初始化时传递给RedisClient。

RedisOptions redisCfg = new RedisOptions().setHost(redisHost).setPort(redisPort).setAuth(redisPassword); 
RedisClient redis = RedisClient.create(vertx, redisCfg)