Skip to content

Instantly share code, notes, and snippets.

@goldmann
Last active September 22, 2016 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goldmann/905413495e520590f7d944868712630c to your computer and use it in GitHub Desktop.
Save goldmann/905413495e520590f7d944868712630c to your computer and use it in GitHub Desktop.

Configuring Active-MQ destinations

Resource

queues-xml.jinja

Environment variables

  • MQ_QUEUES — comma delimited list of queue names

  • MQ_TOPICS — comma delimited list of topic names

Template objects

Following template objects are avaialble:

  • queues — array of queue names

  • topics — array of topic names

def configure_mq_destinations(self):
queues = os.getenv("MQ_QUEUES", "").split(',')
topics = os.getenv("MQ_TOPICS", "").split(',')
destinations = Template(self.get_resource("queues-xml.jinja"))
mq_snippet = destinations.render(queues=queues, topcis=topics)
self.logger.debug(mq_snippet)
xml = XMLEdit("os-eap7-openshift/added/standalone-openshift.xml")
xml.add_element("/ns:server/ns:management/ns:security-realms", mq_snippet)
{% for queue in queues %}
<jms-queue name="{{ queue }}" entries="/queue/{{ queue }}"/>
{% endfor %}
{% for topic in topics %}
<jms-topic name="{{ topic }}" entries="/topic/{{ topic }}"/>
{% endfor %}
function configure_mq_destinations() {
IFS=',' read -a queues <<< ${MQ_QUEUES}
IFS=',' read -a topics <<< ${MQ_TOPICS}
destinations=""
if [ "${#queues[@]}" -ne "0" -o "${#topics[@]}" -ne "0" ]; then
if [ "${#queues[@]}" -ne "0" ]; then
for queue in ${queues[@]}; do
destinations="${destinations}<jms-queue name=\"${queue}\" entries=\"/queue/${queue}\"/>"
done
fi
if [ "${#topics[@]}" -ne "0" ]; then
for topic in ${topics[@]}; do
destinations="${destinations}<jms-topic name=\"${topic}\" entries=\"/topic/${topic}\"/>"
done
fi
fi
echo "${destinations}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment