How to read WildFly and JBoss EAP messaging journal

HornetQ ships with its high performance journal which uses a binary format. We can however have a look through the journal with some helper classes which are bundled in HornetQ JAR files that are part of JBoss EAP and WildFly distribution.

The helper classes which can be used to inspect the journal are located in the org.hornetq.core.persistence.impl.journal package. The most interesting ones for us are the XmlDataExporter class and the PrintData which can be used respectively to dump the journal in XML format or to display the journal and the bindings journal in human readable format.

The helper classes can be executed as standalone main Java classes, though you will need to include a long list of dependencies so probably a Maven project would be needed. I will show how to make it more simply with a bare Servlet which dumps the journal found the the jboss.server.data.dir:

package com.sample;
import java.io.File;
import java.io.IOException;
 
import java.util.logging.Level;
import java.util.logging.Logger;
 
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.hornetq.core.persistence.impl.journal.XmlDataExporter;

 
@WebServlet(name = "xml", urlPatterns = {"/xml"})
public class XMLJournal extends HttpServlet {


    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/xml");

        try {
            String data = System.getProperty("jboss.server.data.dir");
   
            String arg[] = new String[4];
                     
            arg[0] = data +  File.separatorChar + "messagingbindings";
            arg[1] = data +  File.separatorChar + "messagingjournal";
            arg[2] = data +  File.separatorChar + "messagingpaging";
            arg[3] = data +  File.separatorChar + "messaginglargemessages";
                       
         
            XmlDataExporter xmlDataExporter = new XmlDataExporter(response.getOutputStream(), arg[0], arg[1], arg[2], arg[3]);

            xmlDataExporter.writeXMLData();
            response.flushBuffer();

        } catch (Exception ex) {
            Logger.getLogger(TextJournal.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

 
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

 
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

 

}

As you can see, the core part of the Servlet is the XmlDataExporter which takes as parameter the location where the journal files are located and an Output stream. A Servlet has out of the box an Output stream so that makes a perfect match.

Remember to include the org.hornetq dependencies in your application so that you can use the helper classes:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
        <dependencies>
            <module name="org.hornetq"   services="export"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure>

When you execute the Servlet, the journal will be displayed on the screen:

hornetq jboss journal tutorial

A variant to this approach is the org.hornetq.core.persistence.impl.journal.PrintData class which however has not got a suitable constructor to be invoked, so you can just invoke it as follows (of course you can invoke it with the java command shell):

arg[0] = data +  File.separatorChar + "messagingbindings";
arg[1] = data +  File.separatorChar +"messagingjournal";
            
org.hornetq.core.persistence.impl.journal.PrintData.main(arg);

The result, will be a dump of the messaging journal and the bindings journal on the Console:

17:28:53,173 INFO  [stdout] (http-/127.0.0.1:8080-5) Server's ID=8b1ff3bf-eee0-11e5-88b2-eb4fa22fe0e8
17:28:53,173 INFO  [stdout] (http-/127.0.0.1:8080-5) ********************************************
17:28:53,173 INFO  [stdout] (http-/127.0.0.1:8080-5) ********************************************
17:28:53,173 INFO  [stdout] (http-/127.0.0.1:8080-5) B I N D I N G S  J O U R N A L
17:28:53,173 INFO  [stdout] (http-/127.0.0.1:8080-5) ********************************************
17:28:53,175 INFO  [stdout] (http-/127.0.0.1:8080-5) Journal path: /home/francesco/jboss/jboss-eap-6.2/standalone/data/messagingbindings
17:28:53,175 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-bindings-1.bindings id = 1, recordID = 1) (size=1048576)
17:28:53,176 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=2;userRecordType=24;isUpdate=false;IDCounterEncoding [id=2147483647]
17:28:53,177 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecordTX;txID=0,recordID=2;userRecordType=21;isUpdate=false;PersistentQueueBindingEncoding [id=2, name=jms.queue.ExampleQueue, address=jms.queue.ExampleQueue, filterString=null]
17:28:53,177 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@Commit;txID=0,numberOfRecords=1
17:28:53,177 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=9;userRecordType=24;isUpdate=false;IDCounterEncoding [id=9]
17:28:53,178 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=11;userRecordType=24;isUpdate=false;IDCounterEncoding [id=2147483656]
17:28:53,178 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=15;userRecordType=24;isUpdate=false;IDCounterEncoding [id=15]
17:28:53,178 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=17;userRecordType=24;isUpdate=false;IDCounterEncoding [id=2147483662]
17:28:53,179 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecordTX;txID=15,recordID=17;userRecordType=21;isUpdate=false;PersistentQueueBindingEncoding [id=17, name=jms.queue.exampleQueue, address=jms.queue.exampleQueue, filterString=null]
17:28:53,179 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@Commit;txID=15,numberOfRecords=1
17:28:53,179 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=28;userRecordType=24;isUpdate=false;IDCounterEncoding [id=28]
17:28:53,180 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=30;userRecordType=24;isUpdate=false;IDCounterEncoding [id=2147483675]
17:28:53,180 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=55;userRecordType=24;isUpdate=false;IDCounterEncoding [id=55]
17:28:53,180 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=56;userRecordType=24;isUpdate=false;IDCounterEncoding [id=56]
17:28:53,180 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=57;userRecordType=24;isUpdate=false;IDCounterEncoding [id=57]
17:28:53,183 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-bindings-2.bindings id = 8, recordID = 8) (size=1048576)
17:28:53,186 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-bindings-9.bindings id = 9, recordID = 9) (size=1048576)
17:28:53,189 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-bindings-10.bindings id = 10, recordID = 10) (size=1048576)
17:28:53,192 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-bindings-11.bindings id = 11, recordID = 11) (size=1048576)
17:28:53,194 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-bindings-12.bindings id = 12, recordID = 12) (size=1048576)
17:28:53,199 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-bindings-13.bindings id = 13, recordID = 13) (size=1048576)
17:28:53,221 INFO  [stdout] (http-/127.0.0.1:8080-5) 
17:28:53,222 INFO  [stdout] (http-/127.0.0.1:8080-5) ### Surviving Records Summary ###
17:28:53,314 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=2;userRecordType=24;isUpdate=false;IDCounterEncoding [id=2147483647]
17:28:53,314 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=2;userRecordType=21;isUpdate=false;PersistentQueueBindingEncoding [id=2, name=jms.queue.ExampleQueue, address=jms.queue.ExampleQueue, filterString=null]
17:28:53,315 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=9;userRecordType=24;isUpdate=false;IDCounterEncoding [id=9]
17:28:53,315 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=11;userRecordType=24;isUpdate=false;IDCounterEncoding [id=2147483656]
17:28:53,315 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=15;userRecordType=24;isUpdate=false;IDCounterEncoding [id=15]
17:28:53,315 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=17;userRecordType=24;isUpdate=false;IDCounterEncoding [id=2147483662]
17:28:53,315 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=17;userRecordType=21;isUpdate=false;PersistentQueueBindingEncoding [id=17, name=jms.queue.exampleQueue, address=jms.queue.exampleQueue, filterString=null]
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) 
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) ### Prepared TX ###
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) 
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) ### Message Counts ###
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) message count=0
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) message reference count
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) prepared message count=0
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) ********************************************
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) M E S S A G E S   J O U R N A L
17:28:53,316 INFO  [stdout] (http-/127.0.0.1:8080-5) ********************************************
17:28:53,317 INFO  [stdout] (http-/127.0.0.1:8080-5) Journal path: /home/francesco/jboss/jboss-eap-6.2/standalone/data/messagingjournal
17:28:53,318 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-data-1.hq id = 7, recordID = 7) (size=10485760)
17:28:53,327 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=31;userRecordType=31;isUpdate=false;Message(messageID=31;userMessageID=ca31229f-eee4-11e5-b179-f5e0cfcd5079;properties=[__HQ_CID=ca29cf9c-eee4-11e5-b179-f5e0cfcd5079,#properties = 1] - ServerMessage[messageID=31,userID=ca31229f-eee4-11e5-b179-f5e0cfcd5079,priority=4, bodySize=400,expiration=0, durable=true, address=jms.queue.exampleQueue,properties=TypedProperties[{__HQ_CID=ca29cf9c-eee4-11e5-b179-f5e0cfcd5079}]]@1321231452
17:28:53,328 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@Update;recordID=31;userRecordType=32;isUpdate=true;AddRef;QueueEncoding [queueID=17]
17:28:53,329 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=35;userRecordType=31;isUpdate=false;Message(messageID=35;userMessageID=ccd9fb85-eee4-11e5-b179-f5e0cfcd5079;properties=[__HQ_CID=ccd91121-eee4-11e5-b179-f5e0cfcd5079,#properties = 1] - ServerMessage[messageID=35,userID=ccd9fb85-eee4-11e5-b179-f5e0cfcd5079,priority=4, bodySize=400,expiration=0, durable=true, address=jms.queue.exampleQueue,properties=TypedProperties[{__HQ_CID=ccd91121-eee4-11e5-b179-f5e0cfcd5079}]]@1534351401
17:28:53,330 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@Update;recordID=35;userRecordType=32;isUpdate=true;AddRef;QueueEncoding [queueID=17]
17:28:53,332 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=39;userRecordType=31;isUpdate=false;Message(messageID=39;userMessageID=cd4cba8b-eee4-11e5-b179-f5e0cfcd5079;properties=[__HQ_CID=cd4bd027-eee4-11e5-b179-f5e0cfcd5079,#properties = 1] - ServerMessage[messageID=39,userID=cd4cba8b-eee4-11e5-b179-f5e0cfcd5079,priority=4, bodySize=400,expiration=0, durable=true, address=jms.queue.exampleQueue,properties=TypedProperties[{__HQ_CID=cd4bd027-eee4-11e5-b179-f5e0cfcd5079}]]@876201979
17:28:53,332 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@Update;recordID=39;userRecordType=32;isUpdate=true;AddRef;QueueEncoding [queueID=17]
17:28:53,332 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@AddRecord;recordID=43;userRecordType=31;isUpdate=false;Message(messageID=43;userMessageID=cde66281-eee4-11e5-b179-f5e0cfcd5079;properties=[__HQ_CID=cde5781d-eee4-11e5-b179-f5e0cfcd5079,#properties = 1] - ServerMessage[messageID=43,userID=cde66281-eee4-11e5-b179-f5e0cfcd5079,priority=4, bodySize=400,expiration=0, durable=true, address=jms.queue.exampleQueue,properties=TypedProperties[{__HQ_CID=cde5781d-eee4-11e5-b179-f5e0cfcd5079}]]@1675867170
}]]@776789638
17:28:53,335 INFO  [stdout] (http-/127.0.0.1:8080-5) operation@Update;recordID=47;userRecordType=32;isUpdate=true;AddRef;QueueEncoding [queueID=17]
17:28:53,364 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-data-2.hq id = 11, recordID = 11) (size=10485760)
17:28:53,403 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-data-12.hq id = 12, recordID = 12) (size=10485760)
17:28:53,441 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-data-13.hq id = 13, recordID = 13) (size=10485760)
17:28:53,481 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-data-14.hq id = 14, recordID = 14) (size=10485760)
17:28:53,508 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-data-15.hq id = 15, recordID = 15) (size=10485760)
17:28:53,542 INFO  [stdout] (http-/127.0.0.1:8080-5) #JournalFileImpl: (hornetq-data-16.hq id = 16, recordID = 16) (size=10485760)
17:28:53,710 INFO  [stdout] (http-/127.0.0.1:8080-5) 
17:28:53,711 INFO  [stdout] (http-/127.0.0.1:8080-5) ### Surviving Records Summary ###
17:28:54,144 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=31;userRecordType=31;isUpdate=false;Message(messageID=31;userMessageID=ca31229f-eee4-11e5-b179-f5e0cfcd5079;properties=[__HQ_CID=ca29cf9c-eee4-11e5-b179-f5e0cfcd5079,#properties = 1] - ServerMessage[messageID=31,userID=ca31229f-eee4-11e5-b179-f5e0cfcd5079,priority=4, bodySize=400,expiration=0, durable=true, address=jms.queue.exampleQueue,properties=TypedProperties[{__HQ_CID=ca29cf9c-eee4-11e5-b179-f5e0cfcd5079}]]@1468038774
17:28:54,144 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=31;userRecordType=32;isUpdate=true;AddRef;QueueEncoding [queueID=17]
17:28:54,144 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=35;userRecordType=31;isUpdate=false;Message(messageID=35;userMessageID=ccd9fb85-eee4-11e5-b179-f5e0cfcd5079;properties=[__HQ_CID=ccd91121-eee4-11e5-b179-f5e0cfcd5079,#properties = 1] - ServerMessage[messageID=35,userID=ccd9fb85-eee4-11e5-b179-f5e0cfcd5079,priority=4, bodySize=400,expiration=0, durable=true, address=jms.queue.exampleQueue,properties=TypedProperties[{__HQ_CID=ccd91121-eee4-11e5-b179-f5e0cfcd5079}]]@763129186
17:28:54,144 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=35;userRecordType=32;isUpdate=true;AddRef;QueueEncoding [queueID=17]
17:28:54,144 INFO  [stdout] (http-/127.0.0.1:8080-5) recordID=39;userRecordType=31;isUpdate=false;Message(messageID=39;userMessageID=cd4cba8b-eee4-11e5-b179-f5e0cfcd5079;properties=[__HQ_CID=cd4bd027-eee4-11e5-b179-f5e0cfcd5079,#properties = 1] - ServerMessage[messageID=39,userID=cd4cba8b-eee4-11e5-b179-f5e0cfcd5079,priority=4, bodySize=400,expiration=0, durable=true, address=jms.queue.exampleQueue,properties=TypedProperties[{__HQ_CID=cd4bd027-eee4-11e5-b179-f5e0cfcd5079}]]@1396743755
17:28:54,145 INFO  [stdout] (http-/127.0.0.1:8080-5) 
17:28:54,145 INFO  [stdout] (http-/127.0.0.1:8080-5) ### Prepared TX ###
17:28:54,145 INFO  [stdout] (http-/127.0.0.1:8080-5) 
17:28:54,145 INFO  [stdout] (http-/127.0.0.1:8080-5) ### Message Counts ###
17:28:54,145 INFO  [stdout] (http-/127.0.0.1:8080-5) message count=5
17:28:54,145 INFO  [stdout] (http-/127.0.0.1:8080-5) message reference count
17:28:54,145 INFO  [stdout] (http-/127.0.0.1:8080-5) queue id 17,count=5
17:28:54,145 INFO  [stdout] (http-/127.0.0.1:8080-5) prepared message count=0

That's all! hope you find it useful for debugging your messaging issues!

Update for WildFly 10

Are you using WildFly 10 ? then you will find the XmlDataExporter class under the org.apache.artemis.cli.commands.tools package and you will need to use the process method in order to export your journal. Here is a simple main class:

import java.io.File;
import java.io.FileOutputStream;
import org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter;

public class WFReadJournal {

    public static void main(String[] args) throws Exception {
        String server = "server-one";
        String bindings = "/home/jboss/wildfly-10.0.0.Final/domain/servers/" + server + "/data/activemq/bindings";
        String journal = "/home/jboss/wildfly-10.0.0.Final/domain/servers/" + server + "/data/activemq/journal";
        String messagingpaging = "/home/jboss/wildfly-10.0.0.Final/domain/servers/" + server + "/data/paging";
        String largemessages = "/home/jboss/wildfly-10.0.0.Final/domain/servers/" + server + "/data/largemessages";
        File file = new File("/home/jboss/wildfly-10.0.0.Final/domain/servers/" + server + "/journal.xml");

        FileOutputStream fos = new FileOutputStream(file);

        XmlDataExporter xmlDataExporter = new XmlDataExporter();
        xmlDataExporter.process(fos, bindings, journal, messagingpaging, largemessages);

        fos.flush();

    }

}

The following libraries need to be included in your classpath, in order to compile and run your main class:

  • artemis-cli-1.1.0.wildfly-011.jar
  • artemis-server-1.1.0.wildfly-011.jar
  • artemis-core-client-1.1.0.wildfly-011.jar
  • artemis-journal-1.1.0.wildfly-011.jar
  • artemis-commons-1.1.0.wildfly-011.jar
  • jboss-logging-3.3.0.Final.jar
  • netty-all-4.0.32.Final.jar

Related articles available on mastertheboss.com

How to configure a Queue in JBoss ?

This article has been moved here: JBoss JMS configuration

How to create a Queue with Jmx Console ?

  Bring up the JMX Console in your browser and look for the sect

JBoss JMS Queue example

The following article shows how to create a simple JMS Queue Prod

JBoss JMS Topic example

The following article shows how to create a simple JMS Topic Publ

JBoss HornetQ simple tutorial

HornetQ is an open source project to build a multi-protocol, embe

How do I configure a Queue/Topic to work in a cluster?

  JBoss AS 5 Just set the Clustered attribute to "true" in your

Follow us on Twitter