While testing the new JMS 2.0 API, I wanted to see an example of the remote client connecting to a messaging server. I decided to start with the HornetQ messaging server that’s embedded into JBoss Wildfly 8. Folks from JBoss sent me a link to the the GitHub project Wildfly/Quickstart with lots of Wildfly Java EE 7 examples. The HelloWorldJMSClient was the one I was looking for.
The readme file contains detailed instructions on how to compile and run the example. Seeing a requirement to have Maven 3.1 or better looks like an overkill for a helloworld type example. Installed Maven using homebrew – it gave me Maven 3.0.5. Does it mean that helloworld wouldn’t work? Yes it does, but not because of the old maven version. The pom.xml has references to old versions of Wildfly.
In two days I’ll be teaching a JMS class online. Sending students to the maven maze is not appealing to me. Here’s what I suggest. Follow the instructions from the Readme.md to start the Wildfly server, create a user, and a queue. But then, compile and run HelloWorldJMSClient by simply adding jboss-client.jar to the classpath – it has all required JNDI and JMS classes. For example, this is how you can do it from a Terminal window (or a Command Window):
java -cp “.:/Users/yfain11/wildfly-8.0.0.Final/bin/client/jboss-client.jar” org.jboss.as.quickstarts.jms.HelloWorldJMSClient
That’s all. Look ma, no Maven! I sent a GitHub pull request to the Wildfly folks to add this solution to their readme file.
If you like working in IntelliJ IDEA IDE, just add the jboss-client.jar as an external library to your module. If you are an Eclipse fan, go to Project Properties | Build Path and add the jboss-client.jar as an external jar.
A bit later I’m planning to do the same test against GlassFish/OpenMQ combo. I know that in the past they were suggesting using appclient for these purposes, but there should be a simpler way to do stuff.
I’ve been preparing a seminar on JMS and this post is very useful. I’ve also discovered an older material of yours, https://phillyjug.files.wordpress.com/2013/03/usingjavamessagingjug.pdf, that is very helpful as well. I am particularly interested in 2 aspects: JMS applications in the domain of financial systems, and JMS with multithreading. I was wondering if you could recommend some materials that would help me understand the slide titled “Multithreading” (thread pools, using threads to send messages from session beans, instantiating Java listeners on the app server start-up). Kind regards from Bucharest!
Take a look at the Java EE tutorial http://docs.oracle.com/javaee/7/tutorial/partmessaging.htm#GFIRP3
There are plenty of videos on JMS on youtube
Thank you!
Yes, the problem with JMS videos on YouTube is that there are too many 🙂
The JMS&JNDI lesson from your Java video course is the best in my opinion, but it doesn’t answer my question on multithreading.
Being a lazy person, I was looking for an easier way to learn about it than reading the Oracle Tutorial 🙂