How to use environment variables in Artemis MQ XML config?

Out of the box, you cannot directly embed environment variables into Artemis’s broker.xml configuration. You can, however, set System Properties in there, using the following syntax:

      <connectors>
         <connector name="netty-connector">tcp://${amqHost}:${amqPort}</connector>
      </connectors>

Then, you can inject the environment variable in the Java System property using the file artemis.profile which is located under the etc directory of your broker:

 JAVA_ARGS="$JAVA_ARGS -DamqHost=$AMQHOST -DamqPort=$AMQPORT"

Therefore, you have to set the environment variable using your OS’ syntax. For example:

export AMQHOST="192.168.10.1"
export AMQPORT=61617

That’s all. In this short article we have showed a quick hack to inject environment variables into ArtemisMQ configuration.