[jboss-cvs] JBoss Messaging SVN: r5313 - in trunk/src/main/org/jboss/messaging: core/management/impl and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 7 11:31:27 EST 2008
Author: jmesnil
Date: 2008-11-07 11:31:27 -0500 (Fri, 07 Nov 2008)
New Revision: 5313
Modified:
trunk/src/main/org/jboss/messaging/core/management/QueueControlMBean.java
trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
Log:
JBMESSAGIN-1445: add managements methods to move/delete messages matching a message selector
- added methods moveAllMessages(otherQueue), moveMatchingMessages(filter, otherQueue), removeMatchingMessages(filter)
Modified: trunk/src/main/org/jboss/messaging/core/management/QueueControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/QueueControlMBean.java 2008-11-07 16:21:53 UTC (rev 5312)
+++ trunk/src/main/org/jboss/messaging/core/management/QueueControlMBean.java 2008-11-07 16:31:27 UTC (rev 5313)
@@ -89,6 +89,11 @@
@Parameter(name = "messageID", desc = "A message ID") long messageID)
throws Exception;
+ @Operation(desc = "Remove the messages corresponding to the given filter (and returns the number of removed messages)", impact = ACTION)
+ int removeMatchingMessages(
+ @Parameter(name = "filter", desc = "A message filter") String filter)
+ throws Exception;
+
@Operation(desc = "Remove the messages corresponding to the given filter (and returns the number of expired messages)", impact = ACTION)
int expireMessages(
@Parameter(name = "filter", desc = "A message filter") String filter)
@@ -105,6 +110,17 @@
@Parameter(name = "otherQueueName", desc = "The name of the queue to move the message to") String otherQueueName)
throws Exception;
+ @Operation(desc = "Move the messages corresponding to the given filter (and returns the number of moved messages)", impact = ACTION)
+ int moveMatchingMessages(
+ @Parameter(name = "filter", desc = "A message filter") String filter,
+ @Parameter(name = "otherQueueName", desc = "The name of the queue to move the messages to") String otherQueueName)
+ throws Exception;
+
+ @Operation(desc = "Move all the messages to another queue (and returns the number of moved messages)", impact = ACTION)
+ int moveAllMessages(
+ @Parameter(name = "otherQueueName", desc = "The name of the queue to move the messages to") String otherQueueName)
+ throws Exception;
+
@Operation(desc = "Send the message corresponding to the given messageID to this queue's Dead Letter Queue", impact = ACTION)
boolean sendMessageToDLQ(
@Parameter(name = "messageID", desc = "A message ID") long messageID)
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java 2008-11-07 16:21:53 UTC (rev 5312)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java 2008-11-07 16:31:27 UTC (rev 5313)
@@ -23,7 +23,6 @@
package org.jboss.messaging.core.management.impl;
import java.text.DateFormat;
-import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
@@ -252,6 +251,17 @@
throw new IllegalStateException(e.getMessage());
}
}
+
+ public int removeMatchingMessages(String filterStr) throws Exception
+ {
+ Filter filter = filterStr == null ? null : new FilterImpl(new SimpleString(filterStr));
+ List<MessageReference> refs = queue.list(filter);
+ for (MessageReference ref : refs)
+ {
+ removeMessage(ref.getMessage().getMessageID());
+ }
+ return refs.size();
+ }
public boolean expireMessage(final long messageID) throws Exception
{
@@ -293,6 +303,25 @@
return queue.moveMessage(messageID, binding, storageManager, postOffice);
}
+
+ public int moveMatchingMessages(String filterStr, String otherQueueName) throws Exception
+ {
+ Filter filter = filterStr == null ? null : new FilterImpl(new SimpleString(filterStr));
+ List<MessageReference> refs = queue.list(filter);
+ synchronized (queue)
+ {
+ for (MessageReference ref : refs)
+ {
+ moveMessage(ref.getMessage().getMessageID(), otherQueueName);
+ }
+ return refs.size();
+ }
+ }
+
+ public int moveAllMessages(String otherQueueName) throws Exception
+ {
+ return moveMatchingMessages(null, otherQueueName);
+ }
public boolean sendMessageToDLQ(final long messageID) throws Exception
{
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java 2008-11-07 16:21:53 UTC (rev 5312)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java 2008-11-07 16:31:27 UTC (rev 5313)
@@ -82,7 +82,12 @@
boolean removeMessage(
@Parameter(name = "messageID", desc = "A message ID") String messageID)
throws Exception;
-
+
+ @Operation(desc = "Remove the messages corresponding to the given filter (and returns the number of removed messages)", impact = ACTION)
+ int removeMatchingMessages(
+ @Parameter(name = "filter", desc = "A message filter") String filter)
+ throws Exception;
+
@Operation(desc = "Expire the messages corresponding to the given filter (and returns the number of expired messages)", impact = ACTION)
int expireMessages(
@Parameter(name = "filter", desc = "A message filter") String filter)
@@ -104,6 +109,23 @@
@Parameter(name = "newPriority", desc = "the new priority (between 0 and 9)") int newPriority)
throws Exception;
+ @Operation(desc = "Move the message corresponding to the given messageID to another queue", impact = ACTION)
+ boolean moveMessage(
+ @Parameter(name = "messageID", desc = "A message ID") long messageID,
+ @Parameter(name = "otherQueueName", desc = "The name of the queue to move the message to") String otherQueueName)
+ throws Exception;
+
+ @Operation(desc = "Move the messages corresponding to the given filter (and returns the number of moved messages)", impact = ACTION)
+ int moveMatchingMessages(
+ @Parameter(name = "filter", desc = "A message filter") String filter,
+ @Parameter(name = "otherQueueName", desc = "The name of the queue to move the messages to") String otherQueueName)
+ throws Exception;
+
+ @Operation(desc = "Move all the messages to another queue (and returns the number of moved messages)", impact = ACTION)
+ int moveAllMessages(
+ @Parameter(name = "otherQueueName", desc = "The name of the queue to move the messages to") String otherQueueName)
+ throws Exception;
+
CompositeData listMessageCounter();
String listMessageCounterAsHTML();
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java 2008-11-07 16:21:53 UTC (rev 5312)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java 2008-11-07 16:31:27 UTC (rev 5313)
@@ -44,6 +44,7 @@
import org.jboss.messaging.core.messagecounter.MessageCounter.DayCounter;
import org.jboss.messaging.core.messagecounter.impl.MessageCounterHelper;
import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.server.MessageReference;
import org.jboss.messaging.core.server.Queue;
@@ -212,6 +213,26 @@
storageManager);
}
+ public int removeMatchingMessages(String filterStr) throws Exception
+ {
+ try
+ {
+ Filter filter = filterStr == null ? null : new FilterImpl(
+ new SimpleString(SelectorTranslator
+ .convertToJBMFilterString(filterStr)));
+
+ List<MessageReference> refs = coreQueue.list(filter);
+ for (MessageReference ref : refs)
+ {
+ coreQueue.deleteReference(ref.getMessage().getMessageID(), storageManager);
+ }
+ return refs.size();
+ } catch (MessagingException e)
+ {
+ throw new IllegalStateException(e.getMessage());
+ }
+ }
+
public void removeAllMessages() throws Exception
{
coreQueue.deleteAllReferences(storageManager);
@@ -313,7 +334,38 @@
.getMessageID(), (byte) newPriority, storageManager, postOffice,
queueSettingsRepository);
}
+
+ public boolean moveMessage(long messageID, String otherQueueName) throws Exception
+ {
+ Binding binding = postOffice.getBinding(new SimpleString(otherQueueName));
+ if (binding == null)
+ {
+ throw new IllegalArgumentException("No queue found for "
+ + otherQueueName);
+ }
+ return coreQueue.moveMessage(messageID, binding, storageManager, postOffice);
+ }
+
+ public int moveMatchingMessages(String filterStr, String otherQueueName) throws Exception
+ {
+ Filter filter = filterStr == null ? null : new FilterImpl(new SimpleString(filterStr));
+ List<MessageReference> refs = coreQueue.list(filter);
+ synchronized (coreQueue)
+ {
+ for (MessageReference ref : refs)
+ {
+ moveMessage(ref.getMessage().getMessageID(), otherQueueName);
+ }
+ return refs.size();
+ }
+ }
+
+ public int moveAllMessages(String otherQueueName) throws Exception
+ {
+ return moveMatchingMessages(null, otherQueueName);
+ }
+
public CompositeData listMessageCounter()
{
return MessageCounterInfo.toCompositeData(counter);
More information about the jboss-cvs-commits
mailing list