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