Overview
I'm including ant support in order to leverage the core HermesJMS messaging codebase that builds on JMS allowing the reuse of the data held in the Hermes configuration files for batch tasks for development, testing and support - what better than expose Hermes functions for use in the ant?
Configuring Ant
 | Note Ant integration is an experimental feature and feedback to the forums is encouraged. |
Hermes need a couple of system properties set before it will work correctly in Ant, set the ANT_OPTS variable in your system environment to:
| Operating System |
Properties |
| Windows |
-Dlog4j.configuration=file:%HERMES_HOME%/cfg/log4j.ant.props -Dhermes.libs=%HERMES_HOME%/lib |
| Unix |
-Dlog4j.configuration=file:$HERMES_HOME/cfg/log4j.ant.props -Dhermes.libs=$HERMES_HOME/lib |
Invoking
An example file is included in $HERMES_HOME/bin/hermes-tasks.xml that shows how to invoke the three basic tasks:
<project name="hermes-tasks" default="browseActiveMQ" basedir=".">
<taskdef name="browse" classname="hermes.ant.BrowseQueueTask"/>
<taskdef name="putXML" classname="hermes.ant.PutXMLTask"/>
<taskdef name="putText" classname="hermes.ant.PutTextTask"/>
<target name="browseActiveMQ">
<browse hermes="ActiveMQ" queue="Q1" config="../cfg/hermes-config.xml" file="messages.xml"/>
</target>
<target name="putXMLActiveMQ">
<putXML hermes="ActiveMQ" destination="Q1" config="../cfg/hermes-config.xml" file="messages/examples.xml"/>
</target>
<target name="putTextActiveMQ">
<putText hermes="ActiveMQ" destination="Q1" config="../cfg/hermes-config.xml" file="messages/examples.xml"/>
</target>
</project>
To run the tests you'll need to setup a provider using the Hermes GUI, in this case we assume you've got session called ActiveMQ and a queue called Q1. We need to pass in the location of the Hermes libraries to ant so we invoke as:
| Operating System |
Properties |
| Windows |
ant -lib %HERMES_HOME%\lib -buildfile hermes-tasks.xml target |
| Unix |
ant -lib $HERMES_HOME/lib -buildfile hermes-tasks.xml target |
The default target will try and browse the queue and write the messages to the messages.xml file in the current working directory.
Browse Task
This task allows you to read messages from a queue and write them in the Hermes jms2xml.xsd format. The file can then be used as an input for other tasks or for use interactively in the GUI. It currently only works with queues.
| Option |
Description |
| config |
The Hermes configuration XML |
| hermes |
The Hermes session name |
| queue |
The queue name |
| file |
The output file to write the messages to. |
PutXML Task
This tasks takes a file in the Hermes jms2xml.xsd format and sends all the messages in it to the specified queue or topic.
| Option |
Description |
| config |
The Hermes configuration XML |
| hermes |
The Hermes session name |
| destination |
The queue or topic name |
| file |
The source XML file |
PutText Task
This tasks takes a text file and sends it as a single text message to the specified queue or topic.
| Option |
Description |
| config |
The Hermes configuration XML |
| hermes |
The Hermes session name |
| destination |
The queue or topic name |
| file |
The source text file |
RecordMessages Task
This task records messages on a topic or snaps messages from a queue into a JDBC message store. For more information on message stores, read this.
| Option |
Description |
| config |
The Hermes configuration XML |
| hermes |
The Hermes session name |
| queue |
Queue to snap messages from |
| topic |
Topic to record messages from |
| storeId |
The store to record messages to |
| jdbcURL |
Optional. The database to write the messages to, the default is a locally embedded Derby instance |