ActiveMQ
Trenissimo can create an ActiveMQ client to be used in the scripts and the listeners of the simulation.
Quick start
- Open the
build.xmlfile of the simulation, from Trenissimo's Files panel. - Add the namespace declaration for the
com.trenolab.trilogy.activemqmodule in theprojectroot element, like this:<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:trilogy="antlib:com.trenolab.trilogy.ant"
xmlns:if="ant:if"
xmlns:unless="ant:unless"
xmlns:activemq="antlib:com.trenolab.trilogy.activemq"
basedir="."
default="build"
name="Simulation"> - Extend the target
pre-pre-run, this way it is possible to execute the necessary tasks before the start of the simulation<target extensionOf="pre-pre-run" name="pre-pre-run-myapp">
...
</target> - Open the JMS connection. The
brokerUrlparameter is the broker URL, with the standard syntax of ActiveMQ: Broker URI.connectionReferenceis the name of the property to set, which will contain a reference to a JMSConnection<target extensionOf="pre-pre-run" name="pre-pre-run-myapp">
<activemq:openJMSConnection brokerUrl="tcp://127.0.0.1:61616"
connectionReference="jms.connection.ref"/>
<target extensionOf="pre-pre-run" name="pre-pre-run-myapp"> - Pass the reference to the script, for example:
<trilogy:groovySimulationListenersConfiguration scriptFile="myapp.script">
<property name="baseDir" value="${{basedir}}"/>
<reference name="jmsconnection" ref="jms.connection.ref"/>
</trilogy:groovySimulationListenersConfiguration> - Extend the target
post-post-run, this way you can execute the necessary tasks at the end of the simulation<target extensionOf="post-post-run" name="post-post-run-myapp">
...
</target> - Close the connection
<target extensionOf="post-post-run" name="post-post-run-myapp">
<activemq:closeJMSConnection connectionReference="jms.connection.ref"/>
</target>