user1639848
user1639848

Reputation: 572

Configuration system for a long running java process

I am writing a long running java process which is going to poll on an in memory queue and is going to consume items from the queue. I want to have dynamic configurations in this service using zookeeper. I have already written a java class that runs a thread and watches the zookeeper node. On every change to the zookeeper node, an event is triggered and I get the fresh contents of the zookeeper node data. Now the question is:

  1. what should be the encoding for the znode data, one option is to use .properties file like system so just key value pairs and then in my listener set those keys in a config class on change.

  2. does it make sense to write this data to a file and then include that config file in my java program? if I go this way, when a config changes I will have to somehow refresh the contents from the disk. I dont see a particular benefit in writing these configs to a local file. Zookeeper server has enough redundancy and when the service is bounced, the config refresh thread can get all the data for that znode.

Upvotes: 1

Views: 219

Answers (1)

sbridges
sbridges

Reputation: 25150

1) Property files will work fine. java.util.Properties has convenient methods to load and save from a stream. You might want to look at storing the config in a yaml file as well, which allows a bit more than simple key/value pairs.

2) There is no reason to store the config information in two places, if you did so it would be confusing as to which is the true config file.

Upvotes: 1

Related Questions