All you have to do is to call the method:
from the jboss-cli:
/subsystem=messaging/hornetq-server=default/jms-queue=testQueue:remove-messages
I just tried at the exact versions you tried by adding a large ammount of messages, including with paging.. and everything worked fine.
I configured my system to page, and used this to create a few thousand messages:
HornetQConnectionFactory cf = HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
Connection conn = cf.createConnection("guest", "hello");
Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
javax.jms.Queue queue = sess.createQueue("testQueue");
MessageProducer prod = sess.createProducer(queue);
for (int i = 0 ; i < 50000; i++)
{
TextMessage msg = sess.createTextMessage("hello " + i);
prod.send(msg);
if (i % 500 == 0)
{
System.out.println("Sent " + i);
System.out.println("commit");
sess.commit();
}
}
sess.commit();
conn.close();
I then tried the remove method and it worked:
/subsystem=messaging/hornetq-server=default/jms-queue=testQueue:remove-messages
If this is not working there are two possibilities:
We changed how the locks are held on the queue during delivery. Perhaps you are hitting a fixed bug and you would have to move to a newer version.
You have queues in delivery on consumers. We can't delete messages if they are on the Consumer's buffer in delivery state. You would have to remove consumers to delete all messages.
I'm adding this answer here as I did a lot of research trying to replicate your issue and everything worked like a charm. I would need more information to what's going.
I think the best would be the user's forum where we can discuss it further. SOF is going to simple questions / answer. It's not a place for investigating bugs or anything like that.
https://community.jboss.org/en/hornetq?view=discussions