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 TopicControl is used to manage a JMS Topic.
025     * 
026     * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
027     */
028    public interface TopicControl extends DestinationControl
029    {
030       // Attributes ----------------------------------------------------
031    
032       /**
033        * Returns the number of (durable and non-durable) subscribers for this topic.
034        */
035       int getSubscriptionCount();
036    
037       /**
038        * Returns the number of <em>durable</em> subscribers for this topic.
039        */
040       int getDurableSubscriptionCount();
041    
042       /**
043        * Returns the number of <em>non-durable</em> subscribers for this topic.
044        */
045       int getNonDurableSubscriptionCount();
046    
047       /**
048        * Returns the number of messages for all <em>durable</em> subscribers for this topic.
049        */
050       int getDurableMessageCount();
051    
052       /**
053        * Returns the number of messages for all <em>non-durable</em> subscribers for this topic.
054        */
055       int getNonDurableMessageCount();
056    
057       /**
058        * Returns the JNDI bindings associated  to this connection factory.
059        */
060       @Operation(desc = "Returns the list of JNDI bindings associated")
061       String[] getJNDIBindings();
062       
063       /**
064        * Add the JNDI binding to this destination
065        */
066       @Operation(desc = "Add the queue to another JNDI binding")
067       void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception;
068       
069       @Operation(desc = "Add the queue to another JNDI binding")
070       void removeJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception;
071       
072       
073    
074    
075    
076       // Operations ----------------------------------------------------
077    
078       /**
079        * Lists all the subscriptions for this topic (both durable and non-durable).
080        */
081       @Operation(desc = "List all subscriptions")
082       Object[] listAllSubscriptions() throws Exception;
083    
084       /**
085        * Lists all the subscriptions for this topic (both durable and non-durable) using JSON serialization.
086        * <br>
087        * Java objects can be recreated from JSON serialization using {@link SubscriptionInfo#from(String)}.
088        */
089       @Operation(desc = "List all subscriptions")
090       String listAllSubscriptionsAsJSON() throws Exception;
091    
092       /**
093        * Lists all the <em>durable</em> subscriptions for this topic.
094        */
095       @Operation(desc = "List only the durable subscriptions")
096       Object[] listDurableSubscriptions() throws Exception;
097    
098       /**
099        * Lists all the <em>durable</em> subscriptions  using JSON serialization.
100        * <br>
101        * Java objects can be recreated from JSON serialization using {@link SubscriptionInfo#from(String)}.
102        */
103       @Operation(desc = "List only the durable subscriptions")
104       String listDurableSubscriptionsAsJSON() throws Exception;
105    
106       /**
107        * Lists all the <em>non-durable</em> subscriptions for this topic.
108        */
109       @Operation(desc = "List only the non durable subscriptions")
110       Object[] listNonDurableSubscriptions() throws Exception;
111    
112       /**
113        * Lists all the <em>non-durable</em> subscriptions  using JSON serialization.
114        * <br>
115        * Java objects can be recreated from JSON serialization using {@link SubscriptionInfo#from(String)}.
116        */
117       @Operation(desc = "List only the non durable subscriptions")
118       String listNonDurableSubscriptionsAsJSON() throws Exception;
119    
120       /**
121        * Lists all the messages in this queue matching the specified queue representing the subscription.
122        * <br>
123        * 1 Map represents 1 message, keys are the message's properties and headers, values are the corresponding values.
124        */
125       @Operation(desc = "List all the message for the given subscription")
126       public Map<String, Object>[] listMessagesForSubscription(@Parameter(name = "queueName", desc = "the name of the queue representing a subscription") String queueName) throws Exception;
127    
128       /**
129        * Lists all the messages in this queue matching the specified queue representing the subscription using JSON serialization.
130        */
131       @Operation(desc = "List all the message for the given subscription")
132       public String listMessagesForSubscriptionAsJSON(@Parameter(name = "queueName", desc = "the name of the queue representing a subscription") String queueName) throws Exception;
133    
134       /**
135        * Counts the number of messages in the subscription specified by the specified client ID and subscription name. Only messages matching the filter will be counted.
136        * <br>
137        * Using {@code null} or an empty filter will count <em>all</em> messages from this queue.
138        */
139       @Operation(desc = "Count the number of messages matching the filter for the given subscription")
140       public int countMessagesForSubscription(@Parameter(name = "clientID", desc = "the client ID") String clientID,
141                                               @Parameter(name = "subscriptionName", desc = "the name of the durable subscription") String subscriptionName,
142                                               @Parameter(name = "filter", desc = "a JMS filter (can be empty)") String filter) throws Exception;
143    
144       /**
145        * Drops the subscription specified by the specified client ID and subscription name.
146        */
147       @Operation(desc = "Drop a durable subscription", impact = MBeanOperationInfo.ACTION)
148       void dropDurableSubscription(@Parameter(name = "clientID", desc = "the client ID") String clientID,
149                                    @Parameter(name = "subscriptionName", desc = "the name of the durable subscription") String subscriptionName) throws Exception;
150    
151       /**
152        * Drops all subscriptions.
153        */
154       @Operation(desc = "Drop all subscriptions from this topic", impact = MBeanOperationInfo.ACTION)
155       void dropAllSubscriptions() throws Exception;
156    }