Before going to through this post, please read my previous post at “JMS API 1.1 Producer and Consumer” to understand some baby steps to develop JMS 1.1 Producer and Consumer programs.

In this post, we are going to develop a Simple JMS 1.1 Producer and Consumer Example With Eclipse IDE and Embedded JBoss HornetQ Server.

Post Brief TOC

  • Introduction
  • Steps to Develop a JMS V.1.1 Example
  • Final Project Structure
  • Execute and Observe the Output


As a Novice Developer to JMS API, it is bit tough to understand about JMS Servers, ConnectionFactory Creation, Queue Creation, Topic Creation etc. We will discuss these concepts in detail in coming posts. First of all, we should understand how to write a simple JMS Producer and Consumer programs without much effort.

To develop this example, we are going to use Eclipse IDE, JMS 1.1 API, Maven and JBoss Embedded HornetQ JMS Server. It is very easy to configure ConnectionFactory, Queue, Topic etc. with this embedded server. We just need to configure some XML files.

To use Embedded JMS Server, we don’t need to download and install any software. We just need to configure some Jars in our Maven Project. Let’s start developing application now.

Steps to Develop a JMS V.1.1 Example:

NOTE:-This pom.xml contains 3 dependencies

  1. hornetq-core-x.x.jar:- It contains to provide base API for both JMS server and client programs.
  2. hornetq-jms-server-x.x.jar:- It contains API to provide Embedded JBoss HornetQ Server.
  3. hornetq-core-x.x.jar:- It contains JMS API implementation for JMS Session,Queue,Topic etc.
  • Configure one user in “hornetq-users.xml”t o run this program.


Here we have defined one user “jduser” to use them in HornetQ Configuration XML file to configure Security.

  • Configure in-memory server configuration “hornetq-configuration.xml” to run this program. It is used to configure In-Memory JMS Server.


Here We have configured JBoss HornetQ In-Memory Server and Security details.

  • Configure in-memory server ConnectionFactory and Queue “hornetq-jms.xml” to run this program. It is used to configure JMS Settings.


Here we have configured ConnectionFactory with “JDConnectionFactory” name and Queue destination with “/queue/JDQueue” JNDI name. We have linked these two things to previous configured JBoss HornetQ In-Memory Server.

  • Create a Simple Java class “EmbeddedHornetQJMSExample” and copy below sample code.

Just for simplicity, I’ve created both Message Producer and Consumer in a single Java file. Please go through those two sub-sections(separated by comments) for understanding purpose.

Final Project Structure:-

If we observe the project in Eclipse IDE, it’s final structure looks like as below:


Execute and Observe the Output:-

In this section, we will run our JMS Program and observe the results in Eclipse IDE Console.

That’s it all about developing Simple JMS API 1.1 Producer and Consumer application with Embedded JBoss HornetQ Server. We will discuss JMS API 2.0 Producer and Consumer Example in my coming posts.

Please drop me a comment if you like my post or have any issues/suggestions.

By admin

Leave a Reply

%d bloggers like this: