activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r385561 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/jmx/ test/java/org/apache/activemq/broker/jmx/
Date Mon, 13 Mar 2006 14:29:49 GMT
Author: jstrachan
Date: Mon Mar 13 06:29:48 2006
New Revision: 385561

URL: http://svn.apache.org/viewcvs?rev=385561&view=rev
Log:
moved the create/destroy durable subscriptions to the broker MBean to make it easier to use
and not require a reference to the topic to destroy them

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicView.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicViewMBean.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java?rev=385561&r1=385560&r2=385561&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
Mon Mar 13 06:29:48 2006
@@ -23,10 +23,13 @@
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.command.ConsumerId;
+import org.apache.activemq.command.ConsumerInfo;
+import org.apache.activemq.command.RemoveSubscriptionInfo;
 
 public class BrokerView implements BrokerViewMBean {
     
-    private final ManagedRegionBroker broker;
+    final ManagedRegionBroker broker;
 	private final BrokerService brokerService;
 
     public BrokerView(BrokerService brokerService, ManagedRegionBroker managedBroker) throws
Exception {
@@ -138,6 +141,33 @@
 
     public void removeQueue(String name) throws Exception {
         broker.removeDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQQueue(name),
1000);
+    }
+    
+    public void createDurableSubscriber(String clientId, String subscriberName, String topicName,
String selector) throws Exception {
+        ConnectionContext context = new ConnectionContext();
+        context.setBroker(broker);
+        context.setClientId(clientId);
+        ConsumerInfo info = new ConsumerInfo();
+        ConsumerId consumerId = new ConsumerId();
+        consumerId.setConnectionId(clientId);
+        consumerId.setSessionId(0);
+        consumerId.setValue(0);
+        info.setConsumerId(consumerId);
+        info.setDestination(new ActiveMQTopic(topicName));
+        info.setSubcriptionName(subscriberName);
+        info.setSelector(selector);
+        broker.addConsumer(context, info);
+        broker.removeConsumer(context, info);
+    }
+
+    public void destroyDurableSubscriber(String clientId, String subscriberName) throws Exception
{
+        RemoveSubscriptionInfo info = new RemoveSubscriptionInfo();
+        info.setClientId(clientId);
+        info.setSubcriptionName(subscriberName);
+        ConnectionContext context = new ConnectionContext();
+        context.setBroker(broker);
+        context.setClientId(clientId);
+        broker.removeSubscription(context, info);
     }
     
     static public ConnectionContext getConnectionContext(Broker broker) {

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java?rev=385561&r1=385560&r2=385561&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
Mon Mar 13 06:29:48 2006
@@ -18,6 +18,11 @@
 
 import javax.management.ObjectName;
 import org.apache.activemq.Service;
+import org.apache.activemq.broker.ConnectionContext;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.command.ConsumerId;
+import org.apache.activemq.command.ConsumerInfo;
+import org.apache.activemq.command.RemoveSubscriptionInfo;
 
 public interface BrokerViewMBean extends Service {
 
@@ -96,5 +101,23 @@
      * @throws Exception
      */
     public void removeQueue(String name) throws Exception;
+
+    /**
+     * Creates a new durable topic subscriber
+     * 
+     * @param clientId the JMS client ID
+     * @param subscriberName the durable subscriber name
+     * @param topicName the name of the topic to subscribe to
+     * @param selector a selector or null
+     */
+    public void createDurableSubscriber(String clientId, String subscriberName, String topicName,
String selector) throws Exception;
+
+    /**
+     * Destroys a durable subscriber
+     * 
+     * @param clientId the JMS client ID
+     * @param subscriberName the durable subscriber name
+     */
+    public void destroyDurableSubscriber(String clientId, String subscriberName) throws Exception;
     
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicView.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicView.java?rev=385561&r1=385560&r2=385561&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicView.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicView.java
Mon Mar 13 06:29:48 2006
@@ -19,37 +19,10 @@
 import org.apache.activemq.command.ConsumerInfo;
 import org.apache.activemq.command.RemoveSubscriptionInfo;
 
-public class TopicView extends DestinationView implements TopicViewMBean{
-    
-     public TopicView(ManagedRegionBroker broker, Topic destination){
-        super(broker, destination);
-    }
+public class TopicView extends DestinationView implements TopicViewMBean {
 
-    public void createDurableSubscriber(String clientId,String subscriberName) throws Exception{
-        ConnectionContext context = new ConnectionContext();
-        context.setBroker(broker);
-        context.setClientId(clientId);
-        ConsumerInfo info = new ConsumerInfo();
-        ConsumerId consumerId = new ConsumerId();
-        consumerId.setConnectionId(clientId);
-        consumerId.setSessionId(0);
-        consumerId.setValue(0);
-        info.setConsumerId(consumerId);
-        info.setDestination(destination.getActiveMQDestination());
-        info.setSubcriptionName(subscriberName);
-        broker.addConsumer(context, info);
-        broker.removeConsumer(context, info);        
+    public TopicView(ManagedRegionBroker broker, Topic destination) {
+        super(broker, destination);
     }
 
-    public void destroyDurableSubscriber(String clientId,String subscriberName) throws Exception{
-        RemoveSubscriptionInfo info = new RemoveSubscriptionInfo();
-        info.setClientId(clientId);
-        info.setSubcriptionName(subscriberName);
-        ConnectionContext context = new ConnectionContext();
-        context.setBroker(broker);
-        context.setClientId(clientId);
-        broker.removeSubscription(context, info);
-  
-        
-    }
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicViewMBean.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicViewMBean.java?rev=385561&r1=385560&r2=385561&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicViewMBean.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/TopicViewMBean.java
Mon Mar 13 06:29:48 2006
@@ -17,23 +17,4 @@
 package org.apache.activemq.broker.jmx;
 
 public interface TopicViewMBean extends DestinationViewMBean {
-    
-	/**
-	 * Creates a durable subscription that is subscribed to this topic.
-	 * 
-	 * @param clientId
-	 * @param subscriberName
-	 * @throws Exception
-	 */
-    public void createDurableSubscriber(String clientId, String subscriberName) throws Exception;
-
-    /**
-	 * Destroys a durable subscription that had previously subscribed to this topic.
-	 * 
-	 * @param clientId
-	 * @param subscriberName
-	 * @throws Exception
-	 */
-    public void destroyDurableSubscriber(String clientId, String subscriberName) throws Exception;
-
 }

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java?rev=385561&r1=385560&r2=385561&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
Mon Mar 13 06:29:48 2006
@@ -138,14 +138,14 @@
 
         assertEquals("Durable subscriber count", 0, broker.getDurableTopicSubscribers().length);
 
-        ObjectName newTopicName = assertRegisteredObjectName(domain + ":Type=Topic,Destination="
+ getDestinationString() + ",BrokerName=localhost");
-        TopicViewMBean topic = (TopicViewMBean) MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
newTopicName, TopicViewMBean.class, true);
-        topic.createDurableSubscriber(clientID, "subscriber1");
-        topic.createDurableSubscriber(clientID, "subscriber2");
+        String topicName = getDestinationString();
+        String selector = null;
+        broker.createDurableSubscriber(clientID, "subscriber1", topicName , selector);
+        broker.createDurableSubscriber(clientID, "subscriber2", topicName, selector);
         assertEquals("Durable subscriber count", 2, broker.getDurableTopicSubscribers().length);
 
         // now lets try destroy it
-        topic.destroyDurableSubscriber(clientID, "subscriber1");
+        broker.destroyDurableSubscriber(clientID, "subscriber1");
         assertEquals("Durable subscriber count", 1, broker.getDurableTopicSubscribers().length);
     }
 



Mime
View raw message