gaara
gaara

Reputation: 21

How to clear the JMS queue in Jboss

I have a JMS queue in Jboss, and the queue has a messageselector like "UseId = myname". myname is the Id for different users. How can I clear the message in queue while the UseId is equal 0001 ?

Upvotes: 0

Views: 3919

Answers (1)

AndresQ
AndresQ

Reputation: 803

try something like this:

String name = "0001"; // or whatever

Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer mc = sess.createConsumer(queue, "UseId=" + name);

while (mc.receive(100L) != null)
    ;

sess.close();

Upvotes: 3

Related Questions