JBoss HornetQ for Kids, Parents and Grandparents – Chapter 1

It’s now almost 4 years that I’m working with HornetQ and I think it’s time to share part of what I learnt so far.

The main purpose of this post is not to rewrite the official documentation, but it’s to clarify, in simple ways, the concepts we use most here in PaddyPower .

What is HornetQ

HornetQ is a JMS implementation. JMS is a message oriented middle-ware API to exchange information between producers and consumers in an asynchronous way.

HornetQ is one of the numerous framework out there that implement the JMS API.


All the HornetQ configuration we care about is in 1 folder. How beautiful is that?! The folder is hornetq (or hornetq.sar dipending on the jboss version you are using) and you can find it in your jboss profile deploy folder.

In this folder we have up to 7 xml configuration files. We really care only about 2:

  • hornetq-jms.xml and hornetq-configuration.xml.
  • hornetq-jms.xml

This is where you want to define your JNDI names for queues, topics and connection factories.

By default all the Connection factories, the dead letter and the expiry Queue are already configured.

What you need to add is only the queues or topics that your application needs to use.

For example:

<queue name='phaseQueueFromEngine'>
     <entry name='/queue/phaseQueueFromEngine'/>

the entry name is the JNDI name used by your producer and consumer to discover the queue.


This is where you want to define acceptors, connectors, bridges and other cool stuff.

Understanding Connectors & Acceptors

Ok, this can be tricky, so I’ll try to be simple and essential.

HornetQ run in a server (JBoss for example) or as standalone application.

In any of the above cases, HornetQ works by communicating with his own server, the HornetQ server.

In order to communicate with it, we have to tell how we connect to and what we accept as connection.

  • Acceptors define which type of connection are accepted by the HornetQ Server.
  • Connectors define how to connect to the HornetQ server.

Luckily, only 2 kind of connectors and acceptors are possible, in-vm and netty. in-vm is used when the producer and the consumer lives in the same virtual machine.


<acceptor name='in-vm'>
<connector name='in-vm'>

netty is used when the producer and the consumer lives in different virtual machines.


Producer/Consumer in the same machine:

<acceptor name='netty'>
         <param key='host'  value='${host:localhost}'/>
         <param key='port'  value='${port:5445}'/>
<connector name=”netty”>
<param key=”host” value=”${host:localhost}”/>
<param key=”port” value=”${port:5445}”/>

Producer/Consumer in different machines:

Consumer Box

<acceptor name=”netty-external-acceptor”>
<param key=”host” value=”172.x.x.62″/>
<param key=”port” value=”5445″/>

Producer Box

<connector name='remote-engine-connector'>
         <factory-class> org.hornetq.integration.transports.netty.NettyConnectorFactory</factory-class>
         <param key='host' value='172.x.x.62'/>
         <param key='port' value='5445'/>

So far so good.

Pay attention when you configure acceptors and connectors because in order to communicate properly they have to be the same kind with the same host and port.

netty acceptor with netty connector (same host and port )

in-vm acceptor with in-vm connector

in-vm acceptor with netty connector

netty acceptor port 5445 with netty connector 5446

netty acceptor host 172.x.x.60 with netty connector 172.x.x.62

Understanding Bridges

Another feature I widely used is the bridge.

If you have a producer living in the box 172.x.x.60 and the consumer sitting in the box 172.x.x.62 you need to connect them and you do this configuring a bridge in our beloved configuration file hornetq-configuration.xml

Example :

<bridge name=”from60to62Bridge”>
<connector-ref connector-name=”remote-engine-connector”/>

Yes, you use the connector to specify where to connect to the other hornetQ server. Easy!

I hope this will clarify a couple of aspects and it will help to understand better the sometime scary Hornetq configuration.

Coming soon.. HornetQ for Kids, Parents and Grandparents – Chapter 2: the magic of address-settings

Reference: JBoss HornetQ for Kids, Parents and Grandparents – Chapter 1 from our JCG partner Marco Castigliego at the Remove duplication and fix bad names blog.

Related Whitepaper:

Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions

Get ready to program in a whole new way!

Functional Programming in Java will help you quickly get on top of the new, essential Java 8 language features and the functional style that will change and improve your code. This short, targeted book will help you make the paradigm shift from the old imperative way to a less error-prone, more elegant, and concise coding style that’s also a breeze to parallelize. You’ll explore the syntax and semantics of lambda expressions, method and constructor references, and functional interfaces. You’ll design and write applications better using the new standards in Java 8 and the JDK.

Get it Now!  

4 Responses to "JBoss HornetQ for Kids, Parents and Grandparents – Chapter 1"

  1. Idan Fridman says:


    There is ambiguity in your example.

    you saying in-vm is for producer and the consumer lives in the same virtual machine.

    and in other hand you said that with netty the producer and the consumer lives in different virtual machines.

    and then you give this example:

    Producer/Consumer in the same machine:


    2 org.hornetq.integration.transports.netty.NettyAcceptorFactory




    view source







    this example includes netty configuration. and you still wrote above it: “Producer/Consumer in the same machine:”

    Please clarify.


    • marco says:

      Hey Idan,

      You are right, there is a confusion on the following sentence “netty is used when the producer and the consumer lives in different virtual machines.”

      What I should have wrote is “netty must be used when the producer and the consumer lives in different virtual machines.”

      Which it means that netty can be also used on the same virtual machine, but it MUST be used on different virtual machines.

      Thanks for pointing this out.


  2. krishna says:

    Hi i am new to hornetQ implementation,i have some doubts regarding this,can you please help me,i want to implement multiple queues ,is it possible to connect multiple queues?,if yes please give me sample example how to do this.

    Thanks in advance

Leave a Reply

six + = 13

Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below: