Search code examples
jmshornetq

Where to find messages in HornetQ


I have wrote a simple application that sent messages and also receive it in the same application. Now what I want to know is where can I find all the messages sent in HornetQ?


Solution

  • You can check message delivery to HornetQ in two ways.

    Approach 1: Simplest and easy way, using JConsole, Open JConsole from JDK directory and select hornetQ process from local process(I assume you have hornetq in local machine else you need to enable remote JMX) and select connect and go to MBans as shown in below diagram. and select org.hornetq -> Queue -> JMS -> Your Queue -> Attributes. Two parameters message count and message added indicate JMS message status(Note here you cannot read messages)

    enter image description here

    Approach 2: Hermes JMS, Download Hermes JMS(if you are using windows 7 download 1.15 version from here). Install HermesJMS by executing jar. Once HermesJMS install execute hermes.bat in bin directory(if it does not start you need to edit batch file hermes.bat and add set HERMES_CONFIG={valid accessible directory} after set HERMES_HOME).

    Now configure Hermes JMS as follows.

    1. Goto Actions-> New Session, On the popup window click on providers tab at the bottom of the window. right click on classpath groups and select add groups and enter HornetQ and click OK.
    2. Expand hornetQ and right click on library and select add jars add all the following jars after following 3 &4 steps.
    3. Mean time Goto {HermesJMS home directory}\providers create directory HermesJMS and copy following libraries from hornetq\lib directory of hornetq server

      hornetq-core-client.jar
      hornetq-jms-client.jar
      hornetq-logging.jar
      jboss-jms-api.jar
      jnp-client.jar
      netty.jar
      
    4. save and restart the HermesJMS application

    5. Connection Factory sections

      binding = ConnectionFactory
      initialContextFactory = org.jnp.interfaces.NamingContextFactory
      providerURL = jnp://localhost:1099
      urlPkgPrefixes = org.jnp.interfaces:org.jboss.naming
      
    6. Save the settings with name

    7. Right the click on sessions -> new session you created in step 6 and select discover. It will populate all JMS queues.
    8. Now select your target JMS queue and click browse.

    NOTE HoentQ does not store the message once read from your listener, Hence if you need to see the message in HermesJMS you need to read the message after some delay.