如何在顶点内使用ConfigRetriever实例?

时间:2019-04-19 09:57:50

标签: spring spring-boot vert.x reactive

问题:

从spring config服务器的url中获取配置,并在Vertx应用程序的垂直版本中使用它。

我正在从vertx应用程序中的spring-config-server检索配置。 使用.getConfig-> json.result

时,我能够将配置作为JsonObject检索

但是,当我通过设置config来部署verticle时,如何在我的所有ververt中获取此configRetriver对象。

Vertx vertx = Vertx.vertx();
ConfigRetriever configRetriever = ConfigRetriever.create(vertx,new ConfigRetrieverOptions()
.setScanPeriod(30000)
.addStore(new ConfigStoreOptions()
.setType("spring-config-server")
.setConfig(new JsonObject().put("url", "http://myurl"))));

.........Retrieving the configuraton.........

configRetriever.getConfig(json -> {
            JsonObject result = json.result();}));


..........Deploying the Verticle...............
Stream.of(verticles).forEach(verticle -> newVertxInstance.deployVerticle(verticle,
                    new DeploymentOptions().setConfig(result.getJsonObject("source"))
..................

0 个答案:

没有答案