SwiftMQ 4.0.0 introduces a new intra-VM JMS client and includes an implementation of JOnAS' JMS provider interface to start SwiftMQ as an intra-VM service in JOnAS. This has been tested with SwiftMQ 4.0.0 and JOnAS 2.6.
Note that you have to use the JMS XA/ASF Swiftlet!
SwiftMQ 4.x uses JMS 1.1 but JOnAS includes JMS 1.0.2 classes in "lib/jms.jar" so you have to replace it with the router's "jars/jms.jar". Then edit "bin/<platform>/config_env[.bat]" and add "dom4j-full.jar" and "swiftmq.jar" from the router's "jars/" directory to the classpath. Further, edit "bin/<platform>/jclient[.bat]" and add the "swiftmq.jar" to the classpath, otherwise you'll get a ClassCastException when running JOnAS examples because you get a Reference on a JNDI lookup instead of SwiftMQ's connection factory.
SwiftMQ fully integrates with XA/ASF into JOnAS 2.6. The configuration takes place in the "config/jonas.properties" file.
First, enable the JMS service:
In the JMS service configuration, also in "jonas.properties", specify:
# ###################### JOnAS JMS service configuration # # Set the name of the implementation class of the jms service jonas.service.jms.class org.objectweb.jonas.jms.JmsServiceImpl # Indicates the Jms service must be started with this class for administering the mom jonas.service.jms.mom com.swiftmq.appserver.jonas.JmsAdminForSwiftMQ # Set the Jms Server launching mode # If set to 'true' it is launched in the same JVM as EJBServer # If set to 'false' Jms Server is launched in a separate JVM jonas.service.jms.collocated true # Set to the url connexion when the Jms server is not collocated jonas.service.jms.url smqp://intravm/timeout=10000 # Set the list of administered objects topics to be created at EJBServer launching time # If this property isn't set a default topic named sampleTopic is created jonas.service.jms.topics StockHandlerTopic, sampleTopic, mdbTopic # Set the list of administered objecst queuess to be created at EJBServer launching time # If this property isn't set a default queue named sampleQueue is created jonas.service.jms.queues OrdersQueue, sampleQueue
The class "com.swiftmq.appserver.jonas.JmsAdminForSwiftMQ" is our implementation of JOnAS' JMS provider interface. It is part of the swiftmq.jar of the SwiftMQ Router release 3.2.0 and higher. Starting with SwiftMQ 4.0.0, the router can be started intra-VM. This is done by setting the above property "jonas.service.jms.collocated" to "true". The property "jonas.service.jms.url" needs to be "smqp://intravm/timeout=10000" to ensure the JNDI goes via an intra-VM connection as well.
Two system properties needs to be defined (add it in "bin/<platform>/jonas[.bat]"):
"swiftmq.ivm.workingdir" must point to the directory where the "smqr1" etc scripts are located, because any directory references in SwiftMQ's "routerconfig.xml" are relative to this directory. "swiftmq.ivm.configfile" contains the directory/name of the router's configuration file, relative to "swiftmq.ivm.workingdir". Don't specify an absolute path here!
Here is an example from "bin/nt/jonas.bat":
set SWIFTMQ_OPTS=-Dswiftmq.ivm.workingdir=d:/swiftmq_4_0_0/scripts/win32 -Dswiftmq.ivm.configfile=../../config/router1/routerconfig.xml Rem --------------------------------------------- Rem Run java command Rem --------------------------------------------- set BOOT=org.objectweb.jonas.server.Bootstrap if not %MODE%==start goto admin if %WHERE%==foreground %JAVA% %JAVA_OPTS% %SERVLET_OPTS% %SWIFTMQ_OPTS% %BOOT% %CLASS_TO_RUN% if %WHERE%==background start /B %JAVA% %JAVA_OPTS% %SERVLET_OPTS% %SWIFTMQ_OPTS% %BOOT% %CLASS_TO_RUN% if %WHERE%==window start "%HOSTNAME%:%JONASNAME%" %JAVA% %JAVA_OPTS% %SERVLET_OPTS% %SWIFTMQ_OPTS% %BOOT% %CLASS_TO_RUN%
That's it! Start JOnAS which starts SwiftMQ intra-VM, deploy your beans and enjoy!