mirror of https://github.com/apache/activemq.git
added a destroy() method to durable subscription mbeans to make it a bit easier to delete them via JMX. For more background see AMQ-811
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@420835 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ffd1ccb6b8
commit
857cc8c309
|
@ -54,7 +54,7 @@ public interface BrokerViewMBean extends Service {
|
|||
public void terminateJVM(int exitCode);
|
||||
|
||||
/**
|
||||
* Stop the broker and all it's comonents.
|
||||
* Stop the broker and all it's components.
|
||||
*/
|
||||
public void stop() throws Exception;
|
||||
|
||||
|
|
|
@ -16,7 +16,10 @@ package org.apache.activemq.broker.jmx;
|
|||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.TabularData;
|
||||
|
||||
import org.apache.activemq.broker.ConnectionContext;
|
||||
import org.apache.activemq.broker.region.Subscription;
|
||||
import org.apache.activemq.command.RemoveSubscriptionInfo;
|
||||
/**
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
|
@ -62,6 +65,19 @@ public class DurableSubscriptionView extends SubscriptionView implements Durabl
|
|||
return broker.browseAsTable(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the durable subscription so that messages will no longer be stored for this subscription
|
||||
*/
|
||||
public void destroy() throws Exception {
|
||||
RemoveSubscriptionInfo info = new RemoveSubscriptionInfo();
|
||||
info.setClientId(clientId);
|
||||
info.setSubcriptionName(subscriptionName);
|
||||
ConnectionContext context = new ConnectionContext();
|
||||
context.setBroker(broker);
|
||||
context.setClientId(clientId);
|
||||
broker.removeSubscription(context, info);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "InactiveDurableSubscriptionView: " + getClientId() + ":" + getSubscriptionName();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
*/
|
||||
package org.apache.activemq.broker.jmx;
|
||||
|
||||
import org.apache.activemq.broker.ConnectionContext;
|
||||
import org.apache.activemq.command.RemoveSubscriptionInfo;
|
||||
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.TabularData;
|
||||
|
@ -40,4 +43,9 @@ public interface DurableSubscriptionViewMBean extends SubscriptionViewMBean{
|
|||
* @throws OpenDataException
|
||||
*/
|
||||
public TabularData browseAsTable() throws OpenDataException;
|
||||
|
||||
/**
|
||||
* Destroys the durable subscription so that messages will no longer be stored for this subscription
|
||||
*/
|
||||
public void destroy() throws Exception;
|
||||
}
|
|
@ -16,13 +16,19 @@ package org.apache.activemq.broker.jmx;
|
|||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.TabularData;
|
||||
|
||||
import org.apache.activemq.broker.ConnectionContext;
|
||||
import org.apache.activemq.command.RemoveSubscriptionInfo;
|
||||
import org.apache.activemq.command.SubscriptionInfo;
|
||||
|
||||
/**
|
||||
* TODO why does this class not inherit from DurableSubscriptionView?
|
||||
*
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
public class InactiveDurableSubscriptionView extends SubscriptionView implements DurableSubscriptionViewMBean {
|
||||
protected ManagedRegionBroker broker;
|
||||
protected SubscriptionInfo info;
|
||||
protected SubscriptionInfo subscriptionInfo;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -34,7 +40,7 @@ public class InactiveDurableSubscriptionView extends SubscriptionView implements
|
|||
public InactiveDurableSubscriptionView(ManagedRegionBroker broker,String clientId,SubscriptionInfo sub){
|
||||
super(clientId,null);
|
||||
this.broker = broker;
|
||||
this.info = sub;
|
||||
this.subscriptionInfo = sub;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,7 +57,7 @@ public class InactiveDurableSubscriptionView extends SubscriptionView implements
|
|||
* @return the destination name
|
||||
*/
|
||||
public String getDestinationName(){
|
||||
return info.getDestination().getPhysicalName();
|
||||
return subscriptionInfo.getDestination().getPhysicalName();
|
||||
|
||||
}
|
||||
|
||||
|
@ -79,7 +85,7 @@ public class InactiveDurableSubscriptionView extends SubscriptionView implements
|
|||
* @return name of the durable consumer
|
||||
*/
|
||||
public String getSubscriptionName(){
|
||||
return info.getSubcriptionName();
|
||||
return subscriptionInfo.getSubcriptionName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,6 +115,19 @@ public class InactiveDurableSubscriptionView extends SubscriptionView implements
|
|||
return broker.browseAsTable(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the durable subscription so that messages will no longer be stored for this subscription
|
||||
*/
|
||||
public void destroy() throws Exception {
|
||||
RemoveSubscriptionInfo info = new RemoveSubscriptionInfo();
|
||||
info.setClientId(clientId);
|
||||
info.setSubcriptionName(subscriptionInfo.getSubcriptionName());
|
||||
ConnectionContext context = new ConnectionContext();
|
||||
context.setBroker(broker);
|
||||
context.setClientId(clientId);
|
||||
broker.removeSubscription(context, info);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "InactiveDurableSubscriptionView: " + getClientId() + ":" + getSubscriptionName();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue