Subramanian
Subramanian

Reputation: 5902

Java / Java EE setting runtime parameters dynamically

How feasible/practical is it to set system properties at runtime in production environments explicitly? What if there is a web service, that would update system properties - flags mainly. These flags in turn can be used to turn on/off the log-level etc.

The operation would be along these lines:

  1. Set up a web service in the live prod application
  2. access web service [restrict access to specific users] - this would present a UI that would update system properties
  3. application would use the updated system properties going forward

Any suggestion on this approach? Or is it already common occurrence?

Upvotes: 0

Views: 268

Answers (2)

David Blevins
David Blevins

Reputation: 19368

The idea makes some people cringe but does have some appeal... you could store your properties in svn or git and just send out "refresh your config" notifications to the servers via JMS Topic as JB Nizet suggests.

Some nice aspects:

  • all configuration becomes versioned and can be reverted (full edit history)
  • easy to maintain several versions and tell specific servers to "upgrade"
  • someone broke the config! ... svn blame theconfig.properties

The fact that times and names are associated with every edit can make a nice way to know whose cell phone to set on fire.

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 691735

I don't see why it wouldn't work, except if your application is clustered across several JVMs. In this case, you'd better store the configuration in a central database or propagate the change to all the other JVMs using a JMS topic, for example.

If you want to make these system properties persistent after a restart, you'd bette store them in a database as well.

Upvotes: 1

Related Questions