001 /* 002 * Copyright 2009 Red Hat, Inc. 003 * Red Hat licenses this file to you under the Apache License, version 004 * 2.0 (the "License"); you may not use this file except in compliance 005 * with the License. You may obtain a copy of the License at 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * Unless required by applicable law or agreed to in writing, software 008 * distributed under the License is distributed on an "AS IS" BASIS, 009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 010 * implied. See the License for the specific language governing 011 * permissions and limitations under the License. 012 */ 013 014 package org.hornetq.api.jms.management; 015 016 import java.util.Map; 017 018 import javax.management.MBeanOperationInfo; 019 020 import org.hornetq.api.core.management.Operation; 021 import org.hornetq.api.core.management.Parameter; 022 023 /** 024 * A JMSQueueControl is used to manage a JMS queue. 025 * 026 * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a> 027 */ 028 public interface JMSQueueControl extends DestinationControl 029 { 030 // Attributes ---------------------------------------------------- 031 032 /** 033 * Returns the expiry address associated to this queue. 034 */ 035 String getExpiryAddress(); 036 037 /** 038 * Sets the expiry address associated to this queue to the specified expiryAddress. 039 */ 040 void setExpiryAddress(@Parameter(name = "expiryAddress", desc = "Expiry address of the queue") String expiryAddress) throws Exception; 041 042 /** 043 * Returns the dead-letter address associated to this queue. 044 */ 045 String getDeadLetterAddress(); 046 047 /** 048 * Sets the dead-letter address associated to this queue to the specified deadLetterAddress. 049 */ 050 void setDeadLetterAddress(@Parameter(name = "deadLetterAddress", desc = "Dead-letter address of the queue") String deadLetterAddress) throws Exception; 051 052 /** 053 * Returns the number of scheduled messages in this queue. 054 */ 055 long getScheduledCount(); 056 057 /** 058 * Returns the number of consumers consuming messages from this queue. 059 */ 060 int getConsumerCount(); 061 062 /** 063 * returns the selector for the queue 064 */ 065 String getSelector(); 066 067 // Operations ---------------------------------------------------- 068 069 /** 070 * Returns the JNDI bindings associated to this connection factory. 071 */ 072 @Operation(desc = "Returns the list of JNDI bindings associated") 073 String[] getJNDIBindings(); 074 075 /** 076 * Add the JNDI binding to this destination 077 */ 078 @Operation(desc = "Adds the queue to another JNDI binding") 079 void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception; 080 081 @Operation(desc = "Adds the queue to another JNDI binding") 082 void removeJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception; 083 084 085 /** 086 * Lists all the JMS messages in this queue matching the specified filter. 087 * <br> 088 * 1 Map represents 1 message, keys are the message's properties and headers, values are the corresponding values. 089 * <br> 090 * Using {@code null} or an empty filter will list <em>all</em> messages from this queue. 091 */ 092 @Operation(desc = "List all messages in the queue which matches the filter", impact = MBeanOperationInfo.INFO) 093 Map<String, Object>[] listMessages(@Parameter(name = "filter", desc = "A JMS Message filter") String filter) throws Exception; 094 095 /** 096 * Lists all the JMS messages in this queue matching the specified filter using JSON serialization. 097 * <br> 098 * Using {@code null} or an empty filter will list <em>all</em> messages from this queue. 099 */ 100 @Operation(desc = "List all messages in the queue which matches the filter and return them using JSON", impact = MBeanOperationInfo.INFO) 101 String listMessagesAsJSON(@Parameter(name = "filter", desc = "A JMS Message filter (can be empty)") String filter) throws Exception; 102 103 /** 104 * Counts the number of messages in this queue matching the specified filter. 105 * <br> 106 * Using {@code null} or an empty filter will count <em>all</em> messages from this queue. 107 */ 108 @Operation(desc = "Returns the number of the messages in the queue matching the given filter", impact = MBeanOperationInfo.INFO) 109 long countMessages(@Parameter(name = "filter", desc = "A JMS message filter (can be empty)") String filter) throws Exception; 110 111 /** 112 * Removes the message corresponding to the specified message ID. 113 * 114 * @return {@code true} if the message was removed, {@code false} else 115 */ 116 @Operation(desc = "Remove the message corresponding to the given messageID", impact = MBeanOperationInfo.ACTION) 117 boolean removeMessage(@Parameter(name = "messageID", desc = "A message ID") String messageID) throws Exception; 118 119 /** 120 * Removes all the message corresponding to the specified filter. 121 * <br> 122 * Using {@code null} or an empty filter will remove <em>all</em> messages from this queue. 123 * 124 * @return the number of removed messages 125 */ 126 @Operation(desc = "Remove the messages corresponding to the given filter (and returns the number of removed messages)", impact = MBeanOperationInfo.ACTION) 127 int removeMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter) throws Exception; 128 129 /** 130 * Expires all the message corresponding to the specified filter. 131 * <br> 132 * Using {@code null} or an empty filter will expire <em>all</em> messages from this queue. 133 * 134 * @return the number of expired messages 135 */ 136 @Operation(desc = "Expire the messages corresponding to the given filter (and returns the number of expired messages)", impact = MBeanOperationInfo.ACTION) 137 int expireMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter) throws Exception; 138 139 /** 140 * Expires the message corresponding to the specified message ID. 141 * 142 * @return {@code true} if the message was expired, {@code false} else 143 */ 144 @Operation(desc = "Expire the message corresponding to the given messageID", impact = MBeanOperationInfo.ACTION) 145 boolean expireMessage(@Parameter(name = "messageID", desc = "A message ID") String messageID) throws Exception; 146 147 /** 148 * Sends the message corresponding to the specified message ID to this queue's dead letter address. 149 * 150 * @return {@code true} if the message was sent to the dead letter address, {@code false} else 151 */ 152 @Operation(desc = "Send the message corresponding to the given messageID to this queue's Dead Letter Address", impact = MBeanOperationInfo.ACTION) 153 boolean sendMessageToDeadLetterAddress(@Parameter(name = "messageID", desc = "A message ID") String messageID) throws Exception; 154 155 /** 156 * Sends all the message corresponding to the specified filter to this queue's dead letter address. 157 * <br> 158 * Using {@code null} or an empty filter will send <em>all</em> messages from this queue. 159 * 160 * @return the number of sent messages 161 */ 162 @Operation(desc = "Send the messages corresponding to the given filter to this queue's Dead Letter Address", impact = MBeanOperationInfo.ACTION) 163 int sendMessagesToDeadLetterAddress(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filterStr) throws Exception; 164 165 /** 166 * Changes the message's priority corresponding to the specified message ID to the specified priority. 167 * 168 * @param newPriority between 0 and 9 inclusive. 169 * 170 * @return {@code true} if the message priority was changed 171 */ 172 @Operation(desc = "Change the priority of the message corresponding to the given messageID", impact = MBeanOperationInfo.ACTION) 173 boolean changeMessagePriority(@Parameter(name = "messageID", desc = "A message ID") String messageID, 174 @Parameter(name = "newPriority", desc = "the new priority (between 0 and 9)") int newPriority) throws Exception; 175 176 /** 177 * Changes the priority for all the message corresponding to the specified filter to the specified priority. 178 * <br> 179 * Using {@code null} or an empty filter will change <em>all</em> messages from this queue. 180 * 181 * @return the number of changed messages 182 */ 183 @Operation(desc = "Change the priority of the messages corresponding to the given filter", impact = MBeanOperationInfo.ACTION) 184 int changeMessagesPriority(@Parameter(name = "filter", desc = "A message filter") String filter, 185 @Parameter(name = "newPriority", desc = "the new priority (between 0 and 9)") int newPriority) throws Exception; 186 /** 187 * Moves the message corresponding to the specified message ID to the specified other queue. 188 * 189 * @return {@code true} if the message was moved, {@code false} else 190 */ 191 @Operation(desc = "Move the message corresponding to the given messageID to another queue, ignoring duplicates (rejectDuplicates=false on this case)", impact = MBeanOperationInfo.ACTION) 192 boolean moveMessage(@Parameter(name = "messageID", desc = "A message ID") String messageID, 193 @Parameter(name = "otherQueueName", desc = "The name of the queue to move the message to") String otherQueueName) throws Exception; 194 195 196 /** 197 * Moves the message corresponding to the specified message ID to the specified other queue. 198 * 199 * @return {@code true} if the message was moved, {@code false} else 200 */ 201 @Operation(desc = "Move the message corresponding to the given messageID to another queue", impact = MBeanOperationInfo.ACTION) 202 boolean moveMessage(@Parameter(name = "messageID", desc = "A message ID") String messageID, 203 @Parameter(name = "otherQueueName", desc = "The name of the queue to move the message to") String otherQueueName, 204 @Parameter(name = "rejectDuplicates", desc = "Reject messages identified as duplicate by the duplicate message") boolean rejectDuplicates) throws Exception; 205 206 /** 207 * Moves all the message corresponding to the specified filter to the specified other queue. 208 * RejectDuplicates=false on this case 209 * <br> 210 * Using {@code null} or an empty filter will move <em>all</em> messages from this queue. 211 * 212 * @return the number of moved messages 213 */ 214 @Operation(desc = "Move the messages corresponding to the given filter (and returns the number of moved messages). rejectDuplicates=false on this case", impact = MBeanOperationInfo.ACTION) 215 int moveMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter, 216 @Parameter(name = "otherQueueName", desc = "The name of the queue to move the messages to") String otherQueueName) throws Exception; 217 218 /** 219 * Moves all the message corresponding to the specified filter to the specified other queue. 220 * <br> 221 * Using {@code null} or an empty filter will move <em>all</em> messages from this queue. 222 * 223 * @return the number of moved messages 224 */ 225 @Operation(desc = "Move the messages corresponding to the given filter (and returns the number of moved messages)", impact = MBeanOperationInfo.ACTION) 226 int moveMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter, 227 @Parameter(name = "otherQueueName", desc = "The name of the queue to move the messages to") String otherQueueName, 228 @Parameter(name = "rejectDuplicates", desc = "Reject messages identified as duplicate by the duplicate message") boolean rejectDuplicates) throws Exception; 229 230 /** 231 * Lists the message counter for this queue. 232 */ 233 @Operation(desc = "List the message counters", impact = MBeanOperationInfo.INFO) 234 String listMessageCounter() throws Exception; 235 236 /** 237 * Resets the message counter for this queue. 238 */ 239 @Operation(desc = "Reset the message counters", impact = MBeanOperationInfo.INFO) 240 void resetMessageCounter() throws Exception; 241 242 /** 243 * Lists the message counter for this queue as a HTML table. 244 */ 245 @Operation(desc = "List the message counters as HTML", impact = MBeanOperationInfo.INFO) 246 String listMessageCounterAsHTML() throws Exception; 247 248 /** 249 * Lists the message counter history for this queue. 250 */ 251 @Operation(desc = "List the message counters history", impact = MBeanOperationInfo.INFO) 252 String listMessageCounterHistory() throws Exception; 253 254 /** 255 * Lists the message counter history for this queue as a HTML table. 256 */ 257 @Operation(desc = "List the message counters history as HTML", impact = MBeanOperationInfo.INFO) 258 String listMessageCounterHistoryAsHTML() throws Exception; 259 260 /** 261 * Pauses the queue. Messages are no longer delivered to its consumers. 262 */ 263 @Operation(desc = "Pause the queue.", impact = MBeanOperationInfo.ACTION) 264 void pause() throws Exception; 265 266 /** 267 * Returns whether the queue is paused. 268 */ 269 @Operation(desc = "Returns true if the queue is paused.", impact = MBeanOperationInfo.INFO) 270 boolean isPaused() throws Exception; 271 272 /** 273 * Resumes the queue. Messages are again delivered to its consumers. 274 */ 275 @Operation(desc = "Resume the queue.", impact = MBeanOperationInfo.ACTION) 276 void resume() throws Exception; 277 278 @Operation(desc = "List all the existent consumers on the Queue") 279 String listConsumersAsJSON() throws Exception; 280 281 }