User: chirino
Date: 02/03/09 07:32:34
Modified: src/main/org/jboss/mq/server BasicQueue.java
DestinationManager.java JMSDestination.java
JMSQueue.java JMSServer.java JMSTopic.java
QueueManager.java TopicManager.java
Log:
Added some more logic so that you can undeploy a queue or topic. Still needs work
on the recovery side. Queue recovery will only happen the first time the queue is
deployed.
Revision Changes Path
1.15 +7 -1 jbossmq/src/main/org/jboss/mq/server/BasicQueue.java
Index: BasicQueue.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/BasicQueue.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- BasicQueue.java 9 Mar 2002 06:09:32 -0000 1.14
+++ BasicQueue.java 9 Mar 2002 15:32:34 -0000 1.15
@@ -36,7 +36,7 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author David Maplesden ([EMAIL PROTECTED])
* @created August 16, 2001
- * @version $Revision: 1.14 $
+ * @version $Revision: 1.15 $
*/
//abstract public class BasicQueue implements Runnable {
public class BasicQueue {
@@ -145,6 +145,12 @@
} else {
((ClientConsumer)
sub.clientConsumer).removeRemovedSubscription(sub.subscriptionId);
}
+ }
+
+ public boolean isInUse() {
+ synchronized (receivers) {
+ return receivers.size()>0;
+ }
}
public SpyMessage receive(Subscription sub, boolean wait) throws JMSException {
1.2 +9 -3 jbossmq/src/main/org/jboss/mq/server/DestinationManager.java
Index: DestinationManager.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/DestinationManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DestinationManager.java 6 Mar 2002 17:27:51 -0000 1.1
+++ DestinationManager.java 9 Mar 2002 15:32:34 -0000 1.2
@@ -23,7 +23,7 @@
* Super class for destination managers.
*
* @author <a href="[EMAIL PROTECTED]">Peter Antman</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class DestinationManager extends ServiceMBeanSupport
@@ -83,7 +83,7 @@
}
- protected void stopService() throws Exception
+ public void stopService() throws Exception
{
// unbind from JNDI
if (jndiBound) {
@@ -103,6 +103,12 @@
// Set securityConf at manager
getServer().invoke(securityManager,"removeDestination", new
Object[]{spyDest.getName()}, new String[] {"java.lang.String"});
}
+
+ JMSServer jmsServer = (JMSServer)
+ server.getAttribute(jbossMQService, "JMSServer");
+
+ jmsServer.closeDestination(spyDest);
+
log.warn("destination stop not yet fully implemented");
}
@@ -154,7 +160,7 @@
log.info("Bound to JNDI name: " + jndiName);
}
-
+
/**
* Gets the JNDI name use by this topic
*
1.8 +5 -1 jbossmq/src/main/org/jboss/mq/server/JMSDestination.java
Index: JMSDestination.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/JMSDestination.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- JMSDestination.java 2 Feb 2002 03:54:21 -0000 1.7
+++ JMSDestination.java 9 Mar 2002 15:32:34 -0000 1.8
@@ -30,7 +30,7 @@
* @author Hiram Chirino ([EMAIL PROTECTED])
* @author David Maplesden ([EMAIL PROTECTED])
* @created August 16, 2001
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public abstract class JMSDestination {
@@ -77,6 +77,10 @@
public abstract void restoreMessage( MessageReference message );
public abstract void clientConsumerStopped( ClientConsumer clientConsumer );
+ public abstract boolean isInUse();
+
+ public abstract void close() throws JMSException;
+
/**
* @param req org.jboss.mq.AcknowledgementRequest
1.9 +21 -1 jbossmq/src/main/org/jboss/mq/server/JMSQueue.java
Index: JMSQueue.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/JMSQueue.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JMSQueue.java 2 Feb 2002 03:54:21 -0000 1.8
+++ JMSQueue.java 9 Mar 2002 15:32:34 -0000 1.9
@@ -30,7 +30,7 @@
* @author Hiram Chirino ([EMAIL PROTECTED])
* @author David Maplesden ([EMAIL PROTECTED])
* @created August 16, 2001
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
public class JMSQueue extends JMSDestination {
@@ -116,5 +116,25 @@
throws javax.jms.JMSException {
return queue.receive( sub, wait );
}
+ /*
+ * @see JMSDestination#isATopic()
+ */
+
+ /*
+ * @see JMSDestination#isInUse()
+ */
+ public boolean isInUse()
+ {
+ return queue.isInUse();
+ }
+
+ /*
+ * @see JMSDestination#close()
+ */
+ public void close() throws JMSException
+ {
+ server.getPersistenceManager().closeQueue(this, getSpyDestination());
+ }
+
}
1.16 +54 -9 jbossmq/src/main/org/jboss/mq/server/JMSServer.java
Index: JMSServer.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/JMSServer.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- JMSServer.java 6 Mar 2002 17:27:51 -0000 1.15
+++ JMSServer.java 9 Mar 2002 15:32:34 -0000 1.16
@@ -6,6 +6,7 @@
*/
package org.jboss.mq.server;
import java.io.IOException;
+import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
@@ -51,7 +52,7 @@
* @author Hiram Chirino ([EMAIL PROTECTED])
* @author David Maplesden ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>
- * @version $Revision: 1.15 $
+ * @version $Revision: 1.16 $
*/
public class JMSServer implements JMSServerInvoker
{
@@ -820,23 +821,67 @@
* attribute
* @exception JMSException Description of Exception
*/
- public void addDestination(SpyDestination topic, JMSDestination queue) throws
JMSException
+ public void addDestination(JMSDestination destination) throws JMSException
{
if (log.isDebugEnabled())
- log.debug("addDestination: " + topic + ", " + queue);
- if (destinations.containsKey(topic))
- {
- throw new JMSException("This destination already exists !");
+ log.debug("addDestination: " + destination);
+
+ if (destinations.containsKey(destination.getSpyDestination())) {
+ throw new JMSException("This destination has allready been added to the
server!");
}
//Add this new destination to the list
- synchronized (destinations)
- {
+ synchronized (destinations) {
HashMap newMap = (HashMap)destinations.clone();
- newMap.put(topic, queue);
+ newMap.put(destination.getSpyDestination(), destination);
destinations = newMap;
}
+
+ // Restore the messages
+ if( destination instanceof JMSTopic ) {
+ Collection durableSubs =
+
getStateManager().getDurableSubscriptionIdsForTopic((SpyTopic)destination.getSpyDestination());
+ for (Iterator i = durableSubs.iterator(); i.hasNext();)
+ {
+
((JMSTopic)destination).createDurableSubscription((DurableSubscriptionID)i.next());
+ }
+ } else {
+ getPersistenceManager().restoreQueue(destination,
destination.getSpyDestination());
+ }
}
+
+ /**
+ * Closed a destination that was opened previously
+ *
+ * @param dest the destionation to close
+ * @exception JMSException Description of Exception
+ */
+ public void closeDestination(SpyDestination dest) throws JMSException
+ {
+ if (log.isDebugEnabled())
+ log.debug("closeDestination: " + dest);
+
+ JMSDestination destination = (JMSDestination)destinations.get(dest);
+ if (destination == null) {
+ throw new JMSException("This destination is not open!");
+ }
+
+ synchronized (destinations) {
+
+ // Is it in use??
+ if( destination.isInUse() ) {
+ throw new JMSException("The destination is being used.");
+ }
+
+ //remove the destination from the list
+ HashMap newMap = (HashMap)destinations.clone();
+ newMap.remove(dest);
+ destinations = newMap;
+ }
+
+ destination.close();
+ }
+
/**
* #Description of the Method
1.12 +35 -1 jbossmq/src/main/org/jboss/mq/server/JMSTopic.java
Index: JMSTopic.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/JMSTopic.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- JMSTopic.java 6 Mar 2002 17:27:51 -0000 1.11
+++ JMSTopic.java 9 Mar 2002 15:32:34 -0000 1.12
@@ -32,7 +32,7 @@
* @author Hiram Chirino ([EMAIL PROTECTED])
* @author David Maplesden ([EMAIL PROTECTED])
* @created August 16, 2001
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
public class JMSTopic extends JMSDestination {
@@ -134,6 +134,7 @@
cat.error("Could not restore message:", e);
}
}
+
//called by state manager when a durable sub is created
public void createDurableSubscription(DurableSubscriptionID id) throws
JMSException {
if (temporaryDestination != null) {
@@ -148,6 +149,22 @@
}
server.getPersistenceManager().restoreQueue(this, dstopic);
}
+
+ //called by JMSServer when a destination is being closed.
+ public void close() throws JMSException {
+ if (temporaryDestination != null) {
+ throw new JMSException("Not a valid operation on a temporary topic");
+ }
+
+ synchronized (durQueues) {
+ Iterator i = durQueues.values().iterator();
+ while( i.hasNext() ) {
+ PersistentQueue queue = (PersistentQueue)i.next();
+ server.getPersistenceManager().closeQueue(this,
queue.getSpyDestination());
+ }
+ }
+ }
+
//called by state manager when a durable sub is deleted
public void destroyDurableSubscription(DurableSubscriptionID id) throws
JMSException {
@@ -224,5 +241,22 @@
return (BasicQueue) tempQueues.get(sub);
}
}
+ }
+
+ /*
+ * @see JMSDestination#isInUse()
+ */
+ public boolean isInUse()
+ {
+ if (tempQueues.size() > 0)
+ return true;
+ Iterator iter = durQueues.values().iterator();
+ while (iter.hasNext())
+ {
+ PersistentQueue q = (PersistentQueue) iter.next();
+ if (q.isInUse())
+ return true;
+ }
+ return false;
}
}
1.16 +4 -7 jbossmq/src/main/org/jboss/mq/server/QueueManager.java
Index: QueueManager.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/QueueManager.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- QueueManager.java 6 Mar 2002 17:27:51 -0000 1.15
+++ QueueManager.java 9 Mar 2002 15:32:34 -0000 1.16
@@ -17,7 +17,7 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author <a href="[EMAIL PROTECTED]">Hiram Chirino</a>
* @author <a href="[EMAIL PROTECTED]">Peter Antman</a>
- * @version $Revision: 1.15 $
+ * @version $Revision: 1.16 $
*/
public class QueueManager
extends DestinationManager
@@ -40,8 +40,7 @@
{
return destination.queue.messages.size();
}
-
-
+
public void startService() throws Exception
{
if (destinationName == null || destinationName.length() == 0)
@@ -55,8 +54,7 @@
spyDest = new SpyQueue(destinationName);
destination = new JMSQueue((SpyQueue)spyDest, null, jmsServer);
- jmsServer.addDestination((SpyQueue)spyDest, destination);
- jmsServer.getPersistenceManager().restoreQueue(destination,
(SpyQueue)spyDest);
+ jmsServer.addDestination(destination);
if (jndiName == null) {
setJNDIName("queue/" + destinationName);
@@ -66,6 +64,5 @@
setJNDIName(jndiName);
}
super.startService();
- }
-
+ }
}
1.17 +3 -14 jbossmq/src/main/org/jboss/mq/server/TopicManager.java
Index: TopicManager.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/TopicManager.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- TopicManager.java 6 Mar 2002 17:27:51 -0000 1.16
+++ TopicManager.java 9 Mar 2002 15:32:34 -0000 1.17
@@ -21,7 +21,7 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author <a href="[EMAIL PROTECTED]">Hiram Chirino</a>
* @author <a href="[EMAIL PROTECTED]">Peter Antman</a>
- * @version $Revision: 1.16 $
+ * @version $Revision: 1.17 $
*/
public class TopicManager
extends DestinationManager
@@ -53,19 +53,8 @@
spyDest = new SpyTopic(destinationName);
destination = new JMSTopic((SpyTopic)spyDest, null, jmsServer);
- jmsServer.addDestination((SpyTopic)spyDest, destination);
-
- // Is this right?
- StateManager sm = jmsServer.getStateManager();
- Collection durableSubs =
sm.getDurableSubscriptionIdsForTopic((SpyTopic)spyDest);
- for (Iterator i = durableSubs.iterator(); i.hasNext();)
- {
- destination.createDurableSubscription((DurableSubscriptionID)i.next());
- }
-
- // jmsServer.getPersistenceManager().restoreQueue(destination, topic);
- // jmsServer.getPersistenceManager().initQueue(destination);
-
+ jmsServer.addDestination(destination);
+
if (jndiName == null) {
setJNDIName("topic/" + destinationName);
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development