Skip to main content

ActiveMQ

Trenissimo can create an ActiveMQ client to be used in the scripts and the listeners of the simulation.

Quick start

  1. Open the build.xml file of the simulation, from Trenissimo's Files panel.
  2. Add the namespace declaration for the com.trenolab.trilogy.activemq module in the project root 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">
  3. 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>
  4. Open the JMS connection. The brokerUrl parameter is the broker URL, with the standard syntax of ActiveMQ: Broker URI. connectionReference is the name of the property to set, which will contain a reference to a JMS Connection
    <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">
  5. 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>
  6. 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>
  7. Close the connection
     <target extensionOf="post-post-run" name="post-post-run-myapp">
    <activemq:closeJMSConnection connectionReference="jms.connection.ref"/>
    </target>

How it works

Tutorials

Examples

In depth guide