Can not get JMS queued messages from the browser

Solution Unverified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Issue

  • I have the simple code to retrieve messages in the queue, but despite there are and are processed correctly the message browser isn't retrieving any.

  • QueueBrowser is not showing messages which are in-delivery

Resolution

Once a consumer is attached to a queue , then all the messages in the queue are marked for delivery and the status of the messages becomes delivering.

The QueueBrowser does not display the statistics of the in-delivery state messages.

JMX code rather be tried for such situations

public class JMXExample { 
    public static void main(String[] args) throws Exception {
        String host = "localhost";  // Host Name or IP Address of JBoss Server Instance
        int port = 9999;            // Management-native port
        String urlString ="service:jmx:remoting-jmx://" + host + ":" + port;
        System.out.println("\n\n\t****  urlString: "+urlString);

        Hashtable<String,String[]> credentials=new Hashtable<String,String[]>();
        String[] data=new String[]{"admin","admin@123"};   //  <-  This User "userone" belongs to ManagementRealm
        credentials.put("jmx.remote.credentials",data);

        JMXServiceURL serviceURL = new JMXServiceURL(urlString);
        JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, credentials);
        MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();


        ObjectName objectName=new ObjectName("jboss.as:subsystem=messaging,hornetq-server=default,runtime-queue=jms.queue.TestQ");
        long MessageCount=(Long)connection.getAttribute(objectName, "messageCount");


        System.out.println("\n\t   Hornetq Server === : "+MessageCount);
       jmxConnector.close();
    }
}

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.