activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1152747 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java
Date Mon, 01 Aug 2011 11:46:51 GMT
Author: dejanb
Date: Mon Aug  1 11:46:50 2011
New Revision: 1152747

URL: http://svn.apache.org/viewvc?rev=1152747&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3430 - activemq web - session pool

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java?rev=1152747&r1=1152746&r2=1152747&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java Mon
Aug  1 11:46:50 2011
@@ -724,6 +724,15 @@ public class ActiveMQSession implements 
     }
 
     /**
+     * Checks if the session is closed.
+     *
+     * @return true if the session is closed, false otherwise.
+     */
+    public boolean isClosed() {
+        return closed;
+    }
+
+    /**
      * Stops message delivery in this session, and restarts message delivery
      * with the oldest unacknowledged message.
      * <P>

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java?rev=1152747&r1=1152746&r2=1152747&view=diff
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java Mon
Aug  1 11:46:50 2011
@@ -23,13 +23,17 @@ import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
 import javax.jms.Session;
 
+import org.apache.activemq.ActiveMQSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * A simple pool of JMS Session objects intended for use by Queue browsers.
- * 
- * 
  */
 public class SessionPool {
 
+    private static final Logger LOG = LoggerFactory.getLogger(SessionPool.class);
+
     private ConnectionFactory connectionFactory;
     private Connection connection;
     private LinkedList<Session> sessions = new LinkedList<Session>();
@@ -78,8 +82,10 @@ public class SessionPool {
         Session answer = null;
         synchronized (sessions) {
             if (sessions.isEmpty()) {
+                LOG.trace("Creating a new session.");
                 answer = createSession();
             } else {
+                LOG.trace("Serving session from the pool.");
                 answer = sessions.removeLast();
             }
         }
@@ -87,10 +93,13 @@ public class SessionPool {
     }
 
     public void returnSession(Session session) {
-        if (session != null) {
+        if (session != null && !((ActiveMQSession) session).isClosed()) {
             synchronized (sessions) {
+                LOG.trace("Returning session to the pool.");
                 sessions.add(session);
             }
+        } else {
+            LOG.debug("Session closed or null, not returning to the pool.");
         }
     }
 



Mime
View raw message