configurationenvironment-variablesactivemq-artemis

Can I reference environment variables from an Apache ActiveMQ Artemis broker.xml?


As the title says, if I have a variable defined in the same scope as the ActiveMQ Artemis process, can I access it from the configuration XML?


Solution

  • You cannot reference environment variables directly from the broker's configuration XML.

    However, you can use the values of environment variables to set Java "system properties" in etc/artemis.profile and then reference the system properties in the XML. For example, if you had an environment variable named MY_ENV_VAR then you could reference that variable to set a system property by adding a line like this at the end of artemis.profile:

    JAVA_ARGS="$JAVA_ARGS -DmyEnvVar=$MY_ENV_VAR"
    

    Then in the XML you can use that system property via the syntax ${myEnvVar}.

    You can read more about referencing system properties in the XML in the ActiveMQ Artemis documentation.