Stomp is a simple text oriented messaging protocol which has a list of implementations in different languages such as C, C++, Ruby, Python and so on. The Stomp project also provides a protocol translator called StompConnect which translates Stomp into JMS and vice versa. It is therefore possible to access any JMS provider via StompConnect.
SwiftMQ supports the hot deployment (during runtime) of any Java application into a SwiftMQ Router. This can be done with StompConnect as well. However, SwiftMQ requires a shutdown method declared in the application to ensure that all resources are properly being closed during shutdown of the Router or redeployment of the application. StompConnect doesn't have such a shutdown method so we wrote a wrapper which does this and a few more things like providing an intravm connection factory for StompConnect.
Unpack stompconnectwrapper.zip and open the deployment descriptor config.xml with an editor:
<?xml version="1.0" encoding="UTF-8"?>
<deployment-descriptor>
<main-class>com.swiftmq.stompconnect.Wrapper</main-class>
<main-class-arguments>tcp://localhost:61613</main-class-arguments>
<shutdown-method-name>shutdown</shutdown-method-name>
<main-return-is-stop>true</main-return-is-stop>
<startup-delay>2000</startup-delay>
<system-properties>
<system-property name="log4j.configuration" value="file:/Users/am/swiftmq_7_4_0/log4j.properties"/>
</system-properties>
</deployment-descriptor>
The wrapper accepts one optional argument which is the URI to create the Stomp listener. The deployment descriptor contains the default URI. Another configuration option is the log4j configuration file which is specified via system property "log4j.configuration". The log4j.properties we've used looks like this:
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
The deployment takes place in directory "jmsapp/routername" of your SwiftMQ distribution. Switch to that directory and create a subdirectory "stompconnect":
Copy all files from the StompConnect distribution plus the stompconnectwrapper.jar and config.xml into the "stompconnect" subdirectory:
StompConnect is now deployed and will be started from the SwiftMQ Router:
+++ Hot Deployed JMS Application 'stompconnect' started
0 [SwiftMQ-jac.runner-1] INFO org.codehaus.stomp.jms.StompConnect - Looking up name: IVMConnectionFactory in
JNDI InitialContext for JMS ConnectionFactory
41 [SwiftMQ-jac.runner-1] INFO org.codehaus.stomp.tcp.TcpTransportServer - Listening for connections at:
tcp://imac-muelli.local:61613