Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty a jms queue in JBOSS 7 using HornetQ

I am using jboss 7.1.1 final and HornetQ 2.2.13 final.

I have a couple of queues configured and one of them is "full" of messages, couple of thousands. I cant delete the messages.

Ive tried deleting them using jboss cli with the command /subsystem=messaging/hornetq-server=default/jms-queue=Queue:remove-messages

it responds with success, but the messages are still there...

Ive tried deleting them using JConsole with a jmx command. It responds with the number zero and the count messages are still the same.

Ive tried deleting the queue inside Jboss Console and restarting the AS. After I configure the queue again, the messages are still there cause its persisted.

The only way it worked was configuring hornetq server to disable persistence inside standalone.xml.

Does anybody know how to do it using jconsole or jboss cli?

like image 478
Leonardo Porto Avatar asked Oct 08 '13 18:10

Leonardo Porto


1 Answers

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

like image 173
Clebert Suconic Avatar answered Sep 28 '22 11:09

Clebert Suconic