User: chirino
Date: 01/07/28 09:11:36
Modified: src/main/org/jbossmq/server JMSServer.java StateManager.java
StateManagerMBean.java
Log:
While doing integration testing with JBoss MDB I found a few bugs...
Revision Changes Path
1.17 +8 -5 jbossmq/src/main/org/jbossmq/server/JMSServer.java
Index: JMSServer.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jbossmq/server/JMSServer.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- JMSServer.java 2001/07/28 04:07:11 1.16
+++ JMSServer.java 2001/07/28 16:11:36 1.17
@@ -42,7 +42,7 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author Hiram Chirino ([EMAIL PROTECTED])
*
- * @version $Revision: 1.16 $
+ * @version $Revision: 1.17 $
*/
public class JMSServer
{
@@ -374,11 +374,14 @@
//A connection object wants to subscribe to a Destination
public void subscribe(ConnectionToken dc, Subscription sub) throws JMSException
{
- cat.debug("Server:
subscribe(dest="+sub.destination+",idConnection="+dc.getClientID()+")");
-
- ClientConsumer ClientConsumer = getClientConsumer(dc);
-
- ClientConsumer.addSubscription(sub);
+ try {
+ cat.debug("Server:
subscribe(dest="+sub.destination+",idConnection="+dc.getClientID()+")");
+ ClientConsumer ClientConsumer = getClientConsumer(dc);
+ ClientConsumer.addSubscription(sub);
+ } catch ( JMSException e ) {
+ cat.debug("Exception:", e);
+ throw e;
+ }
}
1.5 +92 -83 jbossmq/src/main/org/jbossmq/server/StateManager.java
Index: StateManager.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jbossmq/server/StateManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StateManager.java 2001/07/28 00:30:16 1.4
+++ StateManager.java 2001/07/28 16:11:36 1.5
@@ -36,7 +36,7 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author Hiram Chirino ([EMAIL PROTECTED])
*
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class StateManager extends ServiceMBeanSupport implements StateManagerMBean,
MBeanRegistration {
@@ -200,9 +200,14 @@
category.debug("Restarting Durable Subscription:
"+clientId+","+name+","+topicName);
SpyTopic topic=new SpyTopic(topicName);
-
JMSTopic dest =
(JMSTopic)server.getJMSDestination(topic);
- dest.createDurableSubscription(new
DurableSubcriptionID(clientId, name));
+ if( dest == null ) {
+ category.warn("Subscription topic of not
found: "+topicName);
+ category.warn("Subscription cannot be
initialized: "+clientId+","+name);
+ element.removeFromParent();
+ } else {
+ dest.createDurableSubscription(new
DurableSubcriptionID(clientId, name));
+ }
} catch (JMSException e ) {
category.error("Could not initialize a durable
subscription for : Client Id="+clientId+", Name="+name+", Topic Name="+topicName,e);
@@ -237,89 +242,93 @@
public void setStateFile(java.lang.String newStateFile) {
stateFile = newStateFile;
}
-
- public void setDurableSubscription(JMSServer server, DurableSubcriptionID sub,
SpyTopic topic) throws JMSException {
- category.debug("Checking durable subscription: "+sub+", on topic:
"+topic);
- try {
- //Set the known Ids
- Enumeration enum = stateConfig.getElementsNamed("User");
- while( enum.hasMoreElements() ) {
-
- // Match the User.Name
- XElement user = (XElement)enum.nextElement();
- if( !user.containsField("Id") ||
!user.getField("Id").equals(sub.getClientID()) )
- continue;
-
- category.debug("Found a matching ClientID
configuration section.");
-
-
- XElement subscription=null;
- // Match the User/DurableSubscription.Name
- Enumeration enum2 =
user.getElementsNamed("DurableSubscription");
- while( enum2.hasMoreElements() ) {
- XElement t = (XElement)enum2.nextElement();
- if(
t.getField("Name").equals(sub.getSubscriptionName())) {
- subscription = t;
- break;
- }
- }
+ public String displayStateConfig() throws Exception {
+ return stateConfig.toString();
+ }
- if( subscription == null ) {
- category.debug("The subscription was not
previously registered.");
- // it was not previously registered...
- if( topic == null )
- return;
-
- subscription = new
XElement("DurableSubscription");
- subscription.addField("Name",
sub.getSubscriptionName());
- subscription.addField("TopicName",
topic.getName());
- user.addElement(subscription);
-
- JMSTopic dest =
(JMSTopic)server.getJMSDestination(topic);
- dest.createDurableSubscription(sub);
-
- saveConfig();
-
- } else {
- category.debug("The subscription was
previously registered.");
- // it was previously registered...
- if(
subscription.getField("TopicName").equals(topic.getName()) ) {
- // and it is the same as before, do
nothing.
- return;
- } else {
- category.debug("But the topic was
different, changing the subscription.");
- // we have to change the
subscription...
- SpyTopic prevTopic = new SpyTopic(
subscription.getField("TopicName") );
- JMSTopic dest =
(JMSTopic)server.getJMSDestination(prevTopic);
- dest.destoryDurableSubscription(sub);
-
- if( topic == null ) {
-
subscription.removeFromParent();
- } else {
-
subscription.setField("TopicName", topic.getName());
- dest =
(JMSTopic)server.getJMSDestination(topic);
-
dest.createDurableSubscription(sub);
- }
-
- saveConfig();
- }
- // Subscription existed
- return;
- }
+ public void setDurableSubscription(JMSServer server, DurableSubcriptionID sub,
SpyTopic topic) throws JMSException {
+ category.debug("Checking durable subscription: " + sub + ", on topic: " +
topic);
+ try {
+ //Set the known Ids
+ Enumeration enum= stateConfig.getElementsNamed("User");
+ while (enum.hasMoreElements()) {
+
+ // Match the User.Name
+ XElement user= (XElement) enum.nextElement();
+ if (!user.containsField("Id") ||
!user.getField("Id").equals(sub.getClientID()))
+ continue;
+
+ category.debug("Found a matching ClientID configuration section.");
+
+ XElement subscription= null;
+
+ // Match the User/DurableSubscription.Name
+ Enumeration enum2= user.getElementsNamed("DurableSubscription");
+ while (enum2.hasMoreElements()) {
+ XElement t= (XElement) enum2.nextElement();
+ if (t.getField("Name").equals(sub.getSubscriptionName())) {
+ subscription= t;
+ break;
+ }
+ }
+
+ if (subscription == null) {
+ category.debug("The subscription was not previously
registered.");
+ // it was not previously registered...
+ if (topic == null)
+ return;
+
+ subscription= new XElement("DurableSubscription");
+ subscription.addField("Name", sub.getSubscriptionName());
+ subscription.addField("TopicName", topic.getName());
+ user.addElement(subscription);
+
+ JMSTopic dest= (JMSTopic) server.getJMSDestination(topic);
+ dest.createDurableSubscription(sub);
+
+ saveConfig();
+
+ } else {
+ category.debug("The subscription was previously registered.");
+ // it was previously registered...
+ if
(subscription.getField("TopicName").equals(topic.getName())) {
+ // and it is the same as before, do nothing.
+ return;
+ } else {
+ category.debug("But the topic was different, changing the
subscription.");
+ // we have to change the subscription...
+ SpyTopic prevTopic= new
SpyTopic(subscription.getField("TopicName"));
+ JMSTopic dest= (JMSTopic)
server.getJMSDestination(prevTopic);
+ dest.destoryDurableSubscription(sub);
+
+ if (topic == null) {
+ subscription.removeFromParent();
+ } else {
+ subscription.setField("TopicName", topic.getName());
+ dest= (JMSTopic) server.getJMSDestination(topic);
+ dest.createDurableSubscription(sub);
+ }
+
+ saveConfig();
+ }
+ // Subscription existed
+ }
+ return;
+ }
+
+ // Could not find that user..
+ throw new JMSException("ClientID '" + sub.getClientID() + "'
cannot create durable subscriptions.");
+
+ } catch (java.io.IOException e) {
+ JMSException newE= new JMSException("Could not setup the durable
subscription");
+ newE.setLinkedException(e);
+ throw newE;
+ } catch (org.jbossmq.xml.XElementException e) {
+ JMSException newE= new JMSException("Could not setup the durable
subscription");
+ newE.setLinkedException(e);
+ throw newE;
+ }
- // Could not find that user..
- throw new JMSException("ClientID
'"+sub.getClientID()+"' cannot create durable subscriptions.");
- }
- } catch ( java.io.IOException e ) {
- JMSException newE = new JMSException("Could not setup the
durable subscription");
- newE.setLinkedException(e);
- throw newE;
- } catch ( org.jbossmq.xml.XElementException e ) {
- JMSException newE = new JMSException("Could not setup the
durable subscription");
- newE.setLinkedException(e);
- throw newE;
- }
-
}
}
1.4 +2 -2 jbossmq/src/main/org/jbossmq/server/StateManagerMBean.java
Index: StateManagerMBean.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jbossmq/server/StateManagerMBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StateManagerMBean.java 2001/07/28 00:30:16 1.3
+++ StateManagerMBean.java 2001/07/28 16:11:36 1.4
@@ -55,13 +55,11 @@
*
* @see <related>
* @author Vincent Sheffer ([EMAIL PROTECTED])
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public interface StateManagerMBean
extends org.jboss.util.ServiceMBean
{
-
-
// Public --------------------------------------------------------
@@ -75,4 +73,6 @@
public java.lang.String getStateFile();
public void setStateFile(java.lang.String newStateFile);
+
+ public String displayStateConfig() throws Exception;
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development