How to find a horneq Queue length

hornetq
hornetq tutorial
hornetq vs kafka
hornetq 2.4 0
hornetq jars
hornetq vs activemq
hornetq vs rabbitmq
hornetq docker

I am using Hornetq 2.0 i dont understand how can i know how many message are sitting on the queue at the moment.

This is a very useful feature so i can know at runtime if my consumer consume message fast enough.

I am not using the JMS api but the highly optimised core API.

What is the right (fastest) way to get the number of message in the queue ?

I found 2 way but don't know what is the proper way to do it.

public int size(){

    ClientSession session;

    try {

        session = sf.createSession(false, false, false);

        ClientRequestor requestor = new ClientRequestor(session, "hornetq.management");

        ClientMessage m = session.createMessage(false);

        ManagementHelper.putAttribute(m, "core.queue." + queueName, "messageCount");

        ClientMessage reply = requestor.request(m);

        int count = (Integer) ManagementHelper.getResult(reply);

        return count;

    } catch (Exception e) {

        e.printStackTrace();

    }

    return 0;

}

or

public synchronized int size(){

    ClientSession coreSession = null;

    int count = 0;

    try {

        coreSession = sf.createSession(false, false, false);

        ClientSession.QueueQuery result;

        result = coreSession.queueQuery(new SimpleString(queueName));

        count = result.getMessageCount();

    } catch (HornetQException e) {

        e.printStackTrace();

    } finally {

        if (coreSession!= null ){

            try {

                coreSession.close();

            } catch (HornetQException e) {

                e.printStackTrace();

            }

        }

    }

    return count;

}

I found those 2 ways

public synchronized int size(){
    ClientSession session;
    try {
        session = sf.createSession(false, false, false);
        ClientRequestor requestor = new ClientRequestor(session, "hornetq.management");
        ClientMessage m = session.createMessage(false);
        ManagementHelper.putAttribute(m, "core.queue." + queueName, "messageCount");
        ClientMessage reply = requestor.request(m);
        int count = (Integer) ManagementHelper.getResult(reply);
        return count;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0;
}

and

public synchronized int size(){
    ClientSession coreSession = null;
    int count = 0;
    try {
        coreSession = sf.createSession(false, false, false);
        ClientSession.QueueQuery result;
        result = coreSession.queueQuery(new SimpleString(queueName));
        count = result.getMessageCount();
    } catch (HornetQException e) {
        e.printStackTrace();
    } finally {
        if (coreSession!= null ){
            try {
                coreSession.close();
            } catch (HornetQException e) {
                e.printStackTrace();
            }
        }
    }
    return count;
}

java - How to find a horneq Queue length, I am using Hornetq 2.0 i dont understand how can i know how many message are sitting on the queue at the moment. This is a very useful feature so i can know � By convention, all JMS queues map to core queues where the core queue name has the string jms.queue. prepended to it. E.g. the JMS queue with the name "orders.europe" would map to the core queue with the name "jms.queue.orders.europe". The address at which the core queue is bound is also given by the core queue name.

You have to use the management interface, at the end of this document is an example of retrieving message counts: http://hornetq.sourceforge.net/docs/hornetq-2.0.0.GA/user-manual/en/html/management.html#management.message-counters

Chapter 25. Queue Attributes, The following shows a queue predefined in the hornetq-jms.xml configuration file. expiry-address defines where to send a message that has expired. see here. max-size-bytes and page-size-bytes are used to set paging on an address. Under stationary and free traffic, the queue lengths NGExx(average, 95%, and 99% queue lengths) at GE can be estimated as the product of the average queue length NGEat GE. That is, NGExx ((2) α) =α⋅NGE Eq. (1) consists of 3 terms. The first term describes the queue length at GE.

hornetq-2.2.14.Final ships with an example on message-counters. It's located at hornetq-2.2.14.Final/examples/jms/message-counters

HornetQ User Manual - JBoss Community Confluence, The User manual is an in depth manual on all aspects of HornetQ. Queue with Message Selector; 11.1.48. Reattach Node example You can see from the diagram that the JMS API is implemented by a thin facade layer on the client side. Average queue length is given by E (m) = ρ2/ (1-ρ). m= n-1, being the number of customers in the queue excluding the customer in service. Average length of the nonempty queue E (m│m>0) = ρ2

Out of context but useful, If you're using jboss then you can use below cli command to get queue message count. /subsystem=messaging/hornetq-server=default/jms-queue=:read-attribute(name=message-count)

How to find horneq queue length - java ☕ 🧑 🤝🧑 , I found these 2 ways public synchronized int size(){ ClientSession session; try { session = sf.createSession(false, false, false); ClientRequestor� This can be done by monitoring the Current Disk Queue Length, Avg. Disk Queue Length, % Idle Time, or % Disk Time. The queue length can be quite erratic at times going from 0 to 1000 and back to 0 again in a quick succession, so the Avg. Disk Queue Length is a good choice because it calculates what the queue length might have been on average. We are checking the queue length not because of the number of spindles, but because it means that the disk constantly has work to do.

HornetQ Message Counter Example, Interleaved with the JMS operation, we will retrieve the queue's message retrieve them (see the Management example to learn about managing HornetQ using queue which is sampled (total messages added to the queue, current depth of� HornetQ is an open source project to build a multi-protocol, embeddable, very high performance, clustered, asynchronous messaging system. During much of its development, the HornetQ code base was developed under the name JBoss Messaging 2.0. The HornetQ project is licensed using the Apache Software License v 2.0.

Monitoring HornetQ, For example, counting how many messages there are in a queue is another Managing HornetQ: In this topic we will see what are the core APIs devoted for� Use the following formula to find the Avg. Disk Queue Time: Avg. Queue Time = Disk Queue Length x Avg. Disk sec/Transfer. This will provide you with a relative performance measurement and should be compared with other hard disk drives in your system.

Chapter 30. Management, Using the JMS API -- management operations are sent to HornetQ server using JMS When a queue is paused, it will receive messages but will not deliver them. Diverts parameters can be retrieved using the DivertControl attributes ( see the consumer window size for flow control, isBlockOnNonDurableSend() to know� This name attribute of queue defines the name of the queue. When we do this at a jms level we follow a naming convention so the actual name of the core queue will be jms.queue.selectorQueue. The entry element configures the name that will be used to bind the queue to JNDI. This is a mandatory element and the queue can contain multiple of these