Tutorial: Tomcat / OpenJMS integration
Install and Config
- Let’s assume you would like to run OpenJMS and Tomcat on the same server, eg
myLocalServer
- Download OpenJMS from this page.
- Unzip the archive, extract it to
C:\exe\openjms-0.7.7-beta-1
- Set an environment variable:
set OPENJMS_HOME=C:\exe\openjms-0.7.7-beta-1
- Take the archive
$OPENJMS_HOME/lib/openjms-tunnel-0.7.7-beta-1.war
- copy it to:
$CATALINA_HOME/webapps
- rename it as:
openjms-tunnel.war
- copy it to:
- Edit
OPENJMS_HOME/config/openjms.xml
:- Before the ending tag
</connectors>
, add the block:<Connector scheme="http"> <ConnectionFactories> <ConnectionFactory name="HTTPConnectionFactory"/> </ConnectionFactories> </Connector>
- After the ending tag
</connectors>
, add the block:<HttpConfiguration port="3030" bindAll="true" webServerHost="myLocalServer" webServerPort="8080" servlet="/openjms-tunnel/tunnel"/>
- Before the ending tag
Run applications
- Launch
$OPENJMS_HOME/bin/startup.bat
. The following output is expected:OpenJMS 0.7.7-beta-1 The OpenJMS Group. (C) 1999-2007. All rights reserved. http://openjms.sourceforge.net 15:15:27.531 INFO [Main Thread] - Server accepting connections on tcp://myLocalServer:3035/ 15:15:27.547 INFO [Main Thread] - JNDI service accepting connections on tcp://myLocalServer:3035/ 15:15:27.547 INFO [Main Thread] - Admin service accepting connections on tcp://myLocalServer:3035/ 15:15:27.609 INFO [Main Thread] - Server accepting connections on rmi://myLocalServer:1099/ 15:15:27.609 INFO [Main Thread] - JNDI service accepting connections on rmi://myLocalServer:1099/ 15:15:27.625 INFO [Main Thread] - Admin service accepting connections on rmi://myLocalServer:1099/ 15:15:27.625 INFO [Main Thread] - Server accepting connections on http-server://myLocalServer:3030/ 15:15:27.625 INFO [Main Thread] - JNDI service accepting connections on http-server://myLocalServer:3030/ 15:15:27.625 INFO [Main Thread] - Admin service accepting connections on http-server://myLocalServer:3030/
- Launch Tomcat. A webapp with path
/openjms-tunnel
and display name “OpenJMS HTTP tunnel” should appear.
Checks
-
- Open Console² or an MS-DOS prompt
- Go to
$OPENJMS/examples/basic
- Run:
build
. This will compile all the examples.
Check that OpenJMS is OK:
-
- Edit
jndi.properties
,- Comment the property
java.naming.provider.url
- Add the line:
java.naming.provider.url=tcp://myLocalServer:3035
- Comment the property
- Run:
run Listener queue1
- Open a second tab
- Run:
run Sender queue1 5
- Expected output in the second tab:
C:\exe\openjms-0.7.7-beta-1\examples\basic>run Sender queue1 5 Using OPENJMS_HOME: ..\.. Using JAVA_HOME: C:\exe\beaweblo922\jdk150_10 Using CLASSPATH: .\;..\..\lib\openjms-0.7.7-beta-1.jar Sent: Message 1 Sent: Message 2 Sent: Message 3 Sent: Message 4 Sent: Message 5
- Expected output in the first tab:
C:\exe\openjms-0.7.7-beta-1\examples\basic>run Listener queue1 Using OPENJMS_HOME: C:\exe\openjms-0.7.7-beta-1 Using JAVA_HOME: C:\exe\beaweblo922\jdk150_10 Using CLASSPATH: .\;C:\exe\openjms-0.7.7-beta-1\lib\openjms-0.7.7-beta-1.jar Waiting for messages... Press [return] to quit Received: Message 1 Received: Message 2 Received: Message 3 Received: Message 4 Received: Message 5
- Expected output in the second tab:
- Edit
Check that OpenJMS/Tomcat link is OK:
Manual Check
-
- Stop the
Listener
instance launched sooner - Edit
jndi.properties
,- Comment the line
java.naming.provider.url=tcp://myLocalServer:3035
- Add the line:
java.naming.provider.url=http://myLocalServer:8080
(this is Tomcat manager URL)
- Comment the line
- Run:
run Listener queue1
- Open a second tab
- Run:
run Sender queue1 5
- The expected output are the same as above.
- Stop the
GUI Check
- Stop the
Listener
instance launched sooner - Ensure
jndi.properties
contains the line:java.naming.provider.url=http://myLocalServer:8080
- Run:
$OPENJMS_HOME/bin/admin.bat
- A Swing application should start.
- Go to:
Actions > Connections > Online
- The queue
queue1
should be followed by a ‘0’. - Run:
run Sender queue1 50
-
Action > Refresh
- The queue
queue1
should be followed by a ’50’.
-
- Run:
run Listener queue1
-
Action > Refresh
- The queue
queue1
should be followed by a ‘0’.
-