001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.broker.jmx;
018
019import java.util.Map;
020
021import javax.management.openmbean.CompositeData;
022import javax.management.openmbean.OpenDataException;
023
024public interface QueueViewMBean extends DestinationViewMBean {
025
026    /**
027     * Retrieve a message from the destination's queue.
028     * 
029     * @param messageId the message id of the message to retrieve
030     * @return A CompositeData object which is a JMX version of the messages
031     * @throws OpenDataException
032     */
033    @MBeanInfo("View a message from the destination by JMS message ID.")
034    CompositeData getMessage(@MBeanInfo("messageId") String messageId) throws OpenDataException;
035
036    /**
037     * Removes a message from the queue. If the message has already been
038     * dispatched to another consumer, the message cannot be deleted and this
039     * method will return false.
040     * 
041     * @param messageId
042     * @return true if the message was found and could be successfully deleted.
043     * @throws Exception
044     */
045    @MBeanInfo("Remove a message from the destination by JMS message ID.  If the message has been dispatched, it cannot be deleted and false is returned.")
046    boolean removeMessage(@MBeanInfo("messageId") String messageId) throws Exception;
047
048    /**
049     * Removes the messages matching the given selector
050     * 
051     * @return the number of messages removed
052     */
053    @MBeanInfo("Removes messages from the destination based on an SQL-92 selection on the message headers or XPATH on the body.")
054    int removeMatchingMessages(@MBeanInfo("selector") String selector) throws Exception;
055
056    /**
057     * Removes the messages matching the given selector up to the maximum number
058     * of matched messages
059     * 
060     * @return the number of messages removed
061     */
062    @MBeanInfo("Removes up to a specified number of messages from the destination based on an SQL-92 selection on the message headers or XPATH on the body.")
063    int removeMatchingMessages(@MBeanInfo("selector") String selector, @MBeanInfo("maximumMessages") int maximumMessages) throws Exception;
064
065    /**
066     * Removes all of the messages in the queue.
067     * 
068     * @throws Exception
069     */
070    @MBeanInfo("Removes all of the messages in the queue.")
071    void purge() throws Exception;
072
073    /**
074     * Copies a given message to another destination.
075     * 
076     * @param messageId
077     * @param destinationName
078     * @return true if the message was found and was successfully copied to the
079     *         other destination.
080     * @throws Exception
081     */
082    @MBeanInfo("Copies a message with the given JMS message ID into the specified destination.")
083    boolean copyMessageTo(@MBeanInfo("messageId") String messageId, @MBeanInfo("destinationName") String destinationName) throws Exception;
084
085    /**
086     * Copies the messages matching the given selector
087     * 
088     * @return the number of messages copied
089     */
090    @MBeanInfo("Copies messages based on an SQL-92 selecton on the message headers or XPATH on the body into the specified destination.")
091    int copyMatchingMessagesTo(@MBeanInfo("selector") String selector, @MBeanInfo("destinationName") String destinationName) throws Exception;
092
093    /**
094     * Copies the messages matching the given selector up to the maximum number
095     * of matched messages
096     * 
097     * @return the number of messages copied
098     */
099    @MBeanInfo("Copies up to a specified number of messages based on an SQL-92 selecton on the message headers or XPATH on the body into the specified destination.")
100    int copyMatchingMessagesTo(@MBeanInfo("selector") String selector, @MBeanInfo("destinationName") String destinationName, @MBeanInfo("maximumMessages") int maximumMessages) throws Exception;
101
102    /**
103     * Moves the message to another destination.
104     * 
105     * @param messageId
106     * @param destinationName
107     * @return true if the message was found and was successfully copied to the
108     *         other destination.
109     * @throws Exception
110     */
111    @MBeanInfo("Moves a message with the given JMS message ID into the specified destination.")
112    boolean moveMessageTo(@MBeanInfo("messageId") String messageId, @MBeanInfo("destinationName") String destinationName) throws Exception;
113
114    /**
115     * Moves a message back to its original destination
116     */
117    @MBeanInfo("Moves a message with the given JMS message back to its original destination")
118    boolean retryMessage(@MBeanInfo("messageId") String messageId) throws Exception;
119    
120    /**
121     * Moves the messages matching the given selector
122     * 
123     * @return the number of messages removed
124     */
125    @MBeanInfo("Moves messages based on an SQL-92 selecton on the message headers or XPATH on the body into the specified destination.")
126    int moveMatchingMessagesTo(@MBeanInfo("selector") String selector, @MBeanInfo("destinationName") String destinationName) throws Exception;
127
128    /**
129     * Moves the messages matching the given selector up to the maximum number
130     * of matched messages
131     */
132    @MBeanInfo("Moves up to a specified number of messages based on an SQL-92 selecton on the message headers or XPATH on the body into the specified destination.")
133    int moveMatchingMessagesTo(@MBeanInfo("selector") String selector, @MBeanInfo("destinationName") String destinationName, @MBeanInfo("maximumMessages") int maximumMessages) throws Exception;
134
135    /**
136     * Retries messages sent to the DLQ
137     */
138    @MBeanInfo("Retries messages sent to the DLQ")
139    public int retryMessages() throws Exception;
140    
141    /**
142     * @return true if the message cursor has memory space available
143     * to page in more messages
144     */
145    @MBeanInfo("Message cursor has memory space available")
146    public boolean doesCursorHaveSpace();
147    
148    /**
149     * @return true if the cursor has reached its memory limit for
150     * paged in messages
151     */
152    @MBeanInfo("Message cusor has reached its memory limit for paged in messages")
153    public boolean isCursorFull();
154    
155    /**
156     * @return true if the cursor has messages buffered to deliver
157     */
158    @MBeanInfo("Message cursor has buffered messages to deliver")
159    public boolean doesCursorHaveMessagesBuffered();
160    
161    /**
162     * @return the cursor memory usage in bytes
163     */
164    @MBeanInfo("Message cursor memory usage, in bytes.")
165    public long getCursorMemoryUsage();
166    
167    /**
168     * @return the cursor memory usage as a percentage
169     */
170    @MBeanInfo("Percentage of memory limit used")
171    public int getCursorPercentUsage();
172    
173    /**
174     * @return the number of messages available to be paged in 
175     * by the cursor
176     */
177    @MBeanInfo("Number of messages available to be paged in by the cursor.")
178    public int cursorSize();
179
180    /**
181     * @return true if caching is currently enabled of for the destination
182     */
183    @MBeanInfo("Caching is enabled")
184    boolean isCacheEnabled();
185
186
187    /**
188     * @return a Map of groupNames and ConsumerIds
189     */
190    @MBeanInfo("Map of groupNames and ConsumerIds")
191    Map<String,String> getMessageGroups();
192
193    /**
194     * @return the message group type implementation (simple,bucket,cached)
195     */
196    @MBeanInfo("group  implementation (simple,bucket,cached)")
197    String getMessageGroupType();
198
199    /**
200     * remove a message group = has the effect of rebalancing group
201     * @param groupName
202     */
203
204    @MBeanInfo("remove a message group by its groupName")
205    void removeMessageGroup(@MBeanInfo("groupName")String groupName);
206
207    /**
208     * remove all the message groups - will rebalance all message groups across consumers
209     */
210    @MBeanInfo("emove all the message groups - will rebalance all message groups across consumers")
211    void removeAllMessageGroups();
212
213    @MBeanInfo("pause dispatch to consumers")
214    void pause();
215
216    @MBeanInfo("resume dispatch to consumers if paused")
217    void resume();
218
219    @MBeanInfo("Dispatch to consumers is paused")
220    boolean isPaused();
221
222
223}