Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

This manual shows how to implement the functionality of runtime class redefinition using Dynamic Code Evolution Virtual Machine (DCEVM) and Hotswap Agent in the OpenLMIS application.

This allows the user to make quick changes such as adding and modifying methods, fields, adding new classes and reloading the configuration of frameworks (e.g. changing the 'path' for @RequestMapping).

To provide hot reload functionality for the openlmis microservice, follow these steps:

  1. In the Dockerfile in a specific microservice (e.g. stockmanagement), change the service-base version to v6.1-dcevm.

FROM openlmis/service-base:6.1-dcevm
  1. Add the hotswap-agent.properties file to the resources folder containing the following properties:
    autoHotswap=true
    extraClasspath=${extra.class.path}
    disabledPlugins=${disabled.plugins}

    image-20240222-112921.png
  2. Build a docker image of the microservice (use commands:
    docker-compose -f docker-compose.builder.yml run builder and
    docker-compose -f docker-compose.builder.yml build image).

  3. In the docker-compose.yml file in ref-distro, add the following properties for the microservice:

      environment:
        JAVA_OPTS: "-XXaltjvm=dcevm -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n -Ddisabled.plugins=Proxy
        -javaagent:/opt/hotswap-agent/hotswap-agent.jar=autoHotswap=true -Dextra.class.path=/extra_class_path"
      volumes:
        - (APP_PATH)/build/classes/java/main:/extra_class_path

    *(APP_PATH) is the path to the application on your system. For example:

    image-20240223-080756.png
  4. Start the application (run: docker-compose -f docker-compose.yml up --build --remove-orphans --force-recreate command or start-local.sh)

After making changes to the code, use the command:
docker-compose -f docker-compose.builder.yml run builder
to trigger HotSwapAgent and deliver changes to the running container. To speed up the reload process, you can add options to the build.sh file that allow you to skip some steps included in the builder, e.g. -x test -x integrationTest.

  • No labels