[jboss-cvs] JBoss Messaging SVN: r2046 - in trunk: src/etc/server/default/deploy and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 24 22:00:26 EST 2007
Author: ovidiu.feodorov at jboss.com
Date: 2007-01-24 22:00:26 -0500 (Wed, 24 Jan 2007)
New Revision: 2046
Modified:
trunk/lib/jboss-remoting.jar
trunk/src/etc/server/default/deploy/remoting-service.xml
trunk/src/main/org/jboss/jms/server/ConnectionManager.java
trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-779
Modified: trunk/lib/jboss-remoting.jar
===================================================================
(Binary files differ)
Modified: trunk/src/etc/server/default/deploy/remoting-service.xml
===================================================================
--- trunk/src/etc/server/default/deploy/remoting-service.xml 2007-01-25 01:55:37 UTC (rev 2045)
+++ trunk/src/etc/server/default/deploy/remoting-service.xml 2007-01-25 03:00:26 UTC (rev 2046)
@@ -29,6 +29,7 @@
<attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
<attribute name="NumberOfRetries">1</attribute>
<attribute name="NumberOfCallRetries">1</attribute>
+ <attribute name="callbackErrorsAllowed">1</attribute>
</invoker>
<handlers>
<handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
Modified: trunk/src/main/org/jboss/jms/server/ConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ConnectionManager.java 2007-01-25 01:55:37 UTC (rev 2045)
+++ trunk/src/main/org/jboss/jms/server/ConnectionManager.java 2007-01-25 03:00:26 UTC (rev 2046)
@@ -57,4 +57,11 @@
* @return List<ConnectionEndpoint>
*/
List getActiveConnections();
+
+ /**
+ * @param clientToServer - true if the failure has been detected on a direct connection from
+ * client to this server, false if the failure has been detected while trying to send a
+ * callback from this server to the client.
+ */
+ void handleClientFailure(String remotingSessionID, boolean clientToServer);
}
Modified: trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java 2007-01-25 01:55:37 UTC (rev 2045)
+++ trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java 2007-01-25 03:00:26 UTC (rev 2046)
@@ -129,7 +129,66 @@
}
return null;
}
-
+
+ public synchronized void handleClientFailure(String remotingSessionID, boolean clientToServer)
+ {
+ String jmsClientID = (String)remotingSessions.get(remotingSessionID);
+
+ if (jmsClientID != null)
+ {
+ log.warn(this + " cannot look up remoting session ID " + remotingSessionID);
+ }
+
+ log.warn("A problem has been detected " +
+ (clientToServer ?
+ "with the connection to remote client ":
+ "trying to send a message to remote client ") +
+ remotingSessionID + ". It is possible the client has exited without closing " +
+ "its connection(s) or there is a network problem. All connection resources " +
+ "corresponding to that client process will now be removed.");
+
+ // Remoting only provides one pinger per invoker, not per connection therefore when the pinger
+ // dies we must close ALL connections corresponding to that jms client ID.
+
+ // TODO (ovidiu) In case the error was detected while trying to send a callback, I am assuming
+ // that the whole TCP/IP connection is hosed, so I close everything that's on it. Is this
+ // OK? Maybe we want to be a little bit more selective.
+
+ Map endpoints = (Map)jmsClients.get(jmsClientID);
+
+ if (endpoints != null)
+ {
+ List sces = new ArrayList();
+
+ for(Iterator i = endpoints.entrySet().iterator(); i.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ ConnectionEndpoint sce = (ConnectionEndpoint)entry.getValue();
+ sces.add(sce);
+ }
+
+ // Now close the end points - this will result in a callback into unregisterConnection
+ // to remove the data from the jmsClients and sessions maps.
+ // Note we do this outside the loop to prevent ConcurrentModificationException
+
+ for(Iterator i = sces.iterator(); i.hasNext(); )
+ {
+ ConnectionEndpoint sce = (ConnectionEndpoint)i.next();
+
+ try
+ {
+ sce.closing();
+ sce.close();
+ log.debug("cleared up state for connection " + sce);
+ }
+ catch (JMSException e)
+ {
+ log.error("Failed to close connection", e);
+ }
+ }
+ }
+ }
+
public synchronized List getActiveConnections()
{
// I will make a copy to avoid ConcurrentModification
@@ -138,22 +197,6 @@
return list;
}
- /*
- * Used in testing only
- */
- public synchronized boolean containsRemotingSession(String remotingClientSessionID)
- {
- return remotingSessions.containsKey(remotingClientSessionID);
- }
-
- /*
- * Used in testing only
- */
- public synchronized Map getClients()
- {
- return Collections.unmodifiableMap(jmsClients);
- }
-
// ConnectionListener implementation ------------------------------------------------------------
/**
@@ -178,7 +221,7 @@
if (remotingSessionID != null)
{
- handleClientFailure(remotingSessionID);
+ handleClientFailure(remotingSessionID, true);
}
}
@@ -196,65 +239,23 @@
// Public ---------------------------------------------------------------------------------------
- /**
- * TODO - this method shouldn't be part of the public interace
+ /*
+ * Used in testing only
*/
- public synchronized void handleClientFailure(String remotingSessionID)
+ public synchronized boolean containsRemotingSession(String remotingClientSessionID)
{
- String jmsClientID = (String)remotingSessions.get(remotingSessionID);
+ return remotingSessions.containsKey(remotingClientSessionID);
+ }
- if (jmsClientID != null)
- {
- log.warn("A problem has been detected with the connection to remote client " +
- remotingSessionID + ". It is possible the client has exited without closing " +
- "its connection(s) or there is a network problem. All connection resources " +
- "corresponding to that client process will now be removed.");
+ /*
+ * Used in testing only
+ */
+ public synchronized Map getClients()
+ {
+ return Collections.unmodifiableMap(jmsClients);
+ }
- // Remoting only provides one pinger per invoker, not per connection therefore when the
- // pinger dies we must close ALL the connections corresponding to that jms client id
- Map endpoints = (Map)jmsClients.get(jmsClientID);
-
- if (endpoints != null)
- {
- List sces = new ArrayList();
-
- Iterator iter = endpoints.entrySet().iterator();
-
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
-
- ConnectionEndpoint sce = (ConnectionEndpoint)entry.getValue();
-
- sces.add(sce);
- }
-
- // Now close the end points - this will result in a callback into unregisterConnection
- // to remove the data from the jmsClients and sessions maps.
- // Note we do this outside the loop to prevent ConcurrentModificationException
-
- iter = sces.iterator();
-
- while (iter.hasNext())
- {
- ConnectionEndpoint sce = (ConnectionEndpoint)iter.next();
-
- try
- {
- sce.closing();
- sce.close();
- log.debug("cleared up state for connection " + sce);
- }
- catch (JMSException e)
- {
- log.error("Failed to close connection", e);
- }
- }
- }
- }
- }
-
public String toString()
{
return "ConnectionManager[" + Integer.toHexString(hashCode()) + "]";
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2007-01-25 01:55:37 UTC (rev 2045)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2007-01-25 03:00:26 UTC (rev 2046)
@@ -33,6 +33,7 @@
import org.jboss.jms.server.messagecounter.MessageCounter;
import org.jboss.jms.server.remoting.JMSDispatcher;
import org.jboss.jms.server.remoting.MessagingMarshallable;
+import org.jboss.jms.server.ConnectionManager;
import org.jboss.jms.util.ExceptionUtil;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.Channel;
@@ -250,8 +251,20 @@
}
catch (HandleCallbackException e)
{
- log.error(this + " failed to handle callback", e);
-
+ // it's an oneway callback, so exception could only have happened on the server, while
+ // trying to send the callback. This is a good reason to smack the whole connection.
+ // I trust remoting to have already done its own cleanup via a CallbackErrorHandler,
+ // I need to do my own cleanup at ConnectionManager level.
+
+ log.debug(this + " failed to handle callback", e);
+
+ ServerConnectionEndpoint sce = sessionEndpoint.getConnectionEndpoint();
+ ConnectionManager cm = sce.getServerPeer().getConnectionManager();
+
+ cm.handleClientFailure(sce.getRemotingClientSessionID(), false);
+
+ // we're practically cut, from connection down
+
return null;
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java 2007-01-25 01:55:37 UTC (rev 2045)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java 2007-01-25 03:00:26 UTC (rev 2046)
@@ -119,7 +119,7 @@
// we have removed the exception listener so the server side resouces shouldn't be cleared up
log.info("sleeping for 1 min ...");
- Thread.sleep(10);
+ Thread.sleep(60000);
assertTrue(cm.containsRemotingSession(remotingSessionId));
@@ -136,17 +136,19 @@
prod.send(sess.createMessage());
log.info("sleeping for 45 secs ...");
- Thread.sleep(10);
+ Thread.sleep(45000);
assertFalse(cm.containsRemotingSession(remotingSessionId));
// make sure the message is still in queue
+ conn = cf.createConnection();
+ conn.start();
+ sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer cons = sess.createConsumer(queue);
Message m = cons.receive(1000);
assertNotNull(m);
-
cons.close();
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java 2007-01-25 01:55:37 UTC (rev 2045)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java 2007-01-25 03:00:26 UTC (rev 2046)
@@ -133,7 +133,7 @@
//Simulate failure of connection
- cm.handleClientFailure(sessId1);
+ cm.handleClientFailure(sessId1, true);
//both connections should be shut
@@ -222,7 +222,7 @@
assertFalse(cm.containsRemotingSession("sessionid5"));
- cm.handleClientFailure("sessionid4");
+ cm.handleClientFailure("sessionid4", true);
assertNull(cm.unregisterConnection("jvm2", "sessionid4"));
assertNull(cm.unregisterConnection("jvm2", "sessionid3"));
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2007-01-25 01:55:37 UTC (rev 2045)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2007-01-25 03:00:26 UTC (rev 2046)
@@ -1225,7 +1225,8 @@
"clientSocketClass=org.jboss.jms.client.remoting.ClientSocketWrapper&" +
"serverSocketClass=org.jboss.jms.server.remoting.ServerSocketWrapper&" +
"NumberOfRetries=1&" +
- "NumberOfCallRetries=1;"
+ "NumberOfCallRetries=1&" +
+ "callbackErrorsAllowed=1";
// specific parameters per transport
More information about the jboss-cvs-commits
mailing list