[jboss-cvs] JBoss Messaging SVN: r2638 - in trunk: src/main/org/jboss/jms/server/endpoint and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 4 05:35:14 EDT 2007
Author: timfox
Date: 2007-05-04 05:35:14 -0400 (Fri, 04 May 2007)
New Revision: 2638
Modified:
trunk/src/main/org/jboss/jms/server/ServerPeer.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
trunk/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java
Log:
http://jira.jboss.com/jira/browse/JBMESSAGING-954
Modified: trunk/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-05-04 09:34:46 UTC (rev 2637)
+++ trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-05-04 09:35:14 UTC (rev 2638)
@@ -1235,31 +1235,6 @@
}
}
- public void checkClientID(String clientID) throws Exception
- {
- // verify the clientID is unique
-
- // JMS 1.1 Specifications, Section 4.3.2:
- // "By definition, the client state identified by a client identifier can be 'in use' by
- // only one client at a time. A JMS provider must prevent concurrently executing clients
- // from using it."
-
- if (clientID != null)
- {
- List conns = connectionManager.getActiveConnections();
-
- for(Iterator i = conns.iterator(); i.hasNext(); )
- {
- ServerConnectionEndpoint sce = (ServerConnectionEndpoint)i.next();
- if (clientID != null && clientID.equals(sce.getClientID()))
- {
- throw new InvalidClientIDException(
- "Client ID '" + clientID + "' already used by " + sce);
- }
- }
- }
- }
-
public String toString()
{
return "ServerPeer[" + getServerPeerID() + "]";
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2007-05-04 09:34:46 UTC (rev 2637)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2007-05-04 09:35:14 UTC (rev 2638)
@@ -1294,9 +1294,17 @@
else
{
//Durable sub already exists
-
+
if (trace) { log.trace(this + " subscription " + subscriptionName + " already exists"); }
+ //Check if it is already has a subscriber
+ //We can't have more than one subscriber at a time on the durable sub
+
+ if (binding.getQueue().getNumberOfReceivers() > 0)
+ {
+ throw new IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
+ }
+
// From javax.jms.Session Javadoc (and also JMS 1.1 6.11.1):
// A client can change an existing durable subscription by creating a durable
// TopicSubscriber with the same name and a new topic and/or message selector.
Modified: trunk/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java 2007-05-04 09:34:46 UTC (rev 2637)
+++ trunk/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java 2007-05-04 09:35:14 UTC (rev 2638)
@@ -522,7 +522,36 @@
conn.close();
}
+
+ public void testSubscribeWithActiveSubscription() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+ Topic topic = (Topic)ic.lookup("/topic/Topic");
+ Connection conn = cf.createConnection();
+ conn.setClientID("zeke");
+
+ Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ TopicSubscriber dursub1 = s.createDurableSubscriber(topic, "dursub1");
+
+ try
+ {
+ s.createDurableSubscriber(topic, "dursub1");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ //Ok - it is illegal to have more than one active subscriber on a subscrtiption at any one time
+ }
+
+ dursub1.close();
+
+ s.unsubscribe("dursub1");
+
+ conn.close();
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list