Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Latest commit

 

History

History
45 lines (41 loc) · 1.62 KB

README.adoc

File metadata and controls

45 lines (41 loc) · 1.62 KB

Example

The example shows how to develop a Wildfly Swarm application using the Zookeeper MicroProfile ConfigSource.

An JAX-RS endpoint is provided that has two parameters injected to demonstrate how to read the configuration properties. Initially these properties will return the default values as Zookeeper does not contain data to override them. A Java client is provided which will set the Zookeeper configuration to non-default values. Before running the example you will need a local installation of Apache ZooKeeper. If you have chosen a non-standard hostname and port (default is localhost:2181) you will need to edit the values in src/main/resources/META-INF/microrofile-config.properties

  1. Build the ZkMicroProfileConfigSource library

    $ mvn clean install
  2. Deploy the example application

    $ cd example
    $ mvn clean package wildfly-swarm:run
  3. Go to http://localhost:8080/rest/zkmpcs/injectedValues and the response should be

    *** Injected Property Values ***
    strProp: default_value
    intProp: 8
  4. Run the client to add these values to Zookeeper.

    $ mvn clean package exec:java
  5. Go to http://localhost:8080/rest/zkmpcs/values and the response will be different.

    This endpoint has loaded the properties on demand rather than injecting them. Given that the client has updated Zookeeper with new values for these properties the non-default values are returned.

    *** Retrieved Property Values ***
    refreshedStrProp: zk_value
    refreshedIntProp: 17
  6. If you stop and re-start the Wildfly Swarm application the injected values will come from the ZooKeeper server