ConfigRetriever's listen change handler not getting triggered on a config file change.

103 views
Skip to first unread message

murtuza chhil

unread,
Jan 20, 2018, 1:50:23 AM1/20/18
to vert.x

Hello,

The config retriever's listen handler never gets called when I change the yaml config file.
When I restart the verticle, the new values are picked up.
What am I doing wrong?

        ConfigStoreOptions serverStore = new ConfigStoreOptions().setType("file")
                                                                 .setFormat("yaml")
                                                                 .setConfig(new JsonObject().put("path",
                                                                                                 "server.config.yaml"));
        ConfigRetrieverOptions retrieverOptions = new ConfigRetrieverOptions().setScanPeriod(2000)
                                                                              .addStore(serverStore);
        ConfigRetriever retriever = ConfigRetriever.create(vertx, retrieverOptions);

.....
....

      retriever.listen(change -> {
            // Previous configuration
            JsonObject previous = change.getPreviousConfiguration();
            System.out.println("old config" + previous);
            // New configuration
            config = change.getNewConfiguration();
            System.out.println("new config" + config);
            stopServer();
            opt.setIdleTimeout(config.getJsonObject("tcpserver")
                                     .getInteger("idleConnectionTimeout", 500));
            startServer(opt);

        });


-chhil

murtuza chhil

unread,
Jan 20, 2018, 9:29:46 PM1/20/18
to vert.x
Hi,
Made some progress.
When the file is in the resource folder in my eclipse dev environment, the config gets picked up on verticle start. Changes in the config file don't trigger.
When I moved the file to a different location outside the project, (temp folder) the listen works as expected.
Not to know why its not working when file is under the resource folder.
-chhil

Clement Escoffier

unread,
Jan 21, 2018, 7:16:44 AM1/21/18
to ve...@googlegroups.com
Hi,

How did you setup your redeployment? If you use the vertx maven plugin is should work.

In fact, the `src/main/resources` file is copied (by your build process) to `target/classes`. Your application is using the file located into `target/classes` file. So if you change the file from `src/main/resources`, it won’t detect the change until the files is copied into `target/classes`. The Maven and Gradle plugin are doing this copy for you.

If you use another location (outside of the classpath), it uses the path of the file, so no copy involved in this case.

Clement



-- 
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/1404cb8e-2d0f-4679-aba6-4cb66a67ef37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

murtuza chhil

unread,
Jan 21, 2018, 10:50:09 AM1/21/18
to vert.x
Thanks Clement.
I am simply using the main of the class to run my verticle. Project was setup by a generic grade file to make sure I get the dependencies in.
It pick up the contents when I run it though from the resources folder, that's the confusing part, and I do understand it would get copied to the target folder and used from there. But since I don't build using grade I am confused about it picking up the file in the first place.

-chhil

Clement Escoffier

unread,
Jan 21, 2018, 12:18:41 PM1/21/18
to ve...@googlegroups.com
Which IDE are you using? Some IDE do things under the hood.

Clement

>
> -chhil
>
> --
> You received this message because you are subscribed to the Google Groups "vert.x" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
> Visit this group at https://groups.google.com/group/vertx.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/3170deba-8710-425c-8be9-63e02fddf4c7%40googlegroups.com.

murtuza chhil

unread,
Jan 21, 2018, 8:23:09 PM1/21/18
to vert.x
Hi Clement,


Was never running the project using gradle, simply through eclipses run menu.
Started using the vertx gradle plugin now.

Thank you for your assistance.

-chhil
Reply all
Reply to author
Forward
0 new messages