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.
Recommended Articles
Secure WildFly Connection to Remote Artemis MQ Broker with SSL
Learn how to connect WildFly to a remote Artemis MQ broker using SSL for secure communication. Get step-by-step guide and configuration details.
Mastering MQTT Connectivity with Artemis Broker - A Step-by-Step Java Tutorial
Learn how to use MQTT protocol with Artemis broker in this comprehensive Java tutorial. #MQTT #ArtemisBroker #JavaTutorials
Configure ActiveMQ with Advanced Transport Connectors and Broker XBean URI
Learn how to configure ActiveMQ for various protocols like OpenWire, AMQP, STOMP, MQTT, and WS, as well as customize startup settings using the Broker XBean URI.
Second Tutorial: Integrating WildFly with Apache ActiveMQ Broker Using Resource Adapter
Learn how to deploy an ActiveMQ resource adapter as a module in WildFly and configure connections, queues. Prerequisites: JBoss EAP 6.1+/Wildfly.