activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r418285 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq: ActiveMQSession.java ActiveMQSessionExecutor.java
Date Fri, 30 Jun 2006 13:48:31 GMT
Author: chirino
Date: Fri Jun 30 06:48:30 2006
New Revision: 418285

URL: http://svn.apache.org/viewvc?rev=418285&view=rev
Log:
If sessionAsyncDispatch==false we do not need to create a session thread.


Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java?rev=418285&r1=418284&r2=418285&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
Fri Jun 30 06:48:30 2006
@@ -72,7 +72,6 @@
 import org.apache.activemq.management.StatsCapable;
 import org.apache.activemq.management.StatsImpl;
 import org.apache.activemq.thread.Scheduler;
-import org.apache.activemq.thread.TaskRunner;
 import org.apache.activemq.transaction.Synchronization;
 import org.apache.activemq.util.Callback;
 import org.apache.activemq.util.LongSequenceGenerator;
@@ -198,7 +197,6 @@
     protected boolean closed;
     protected boolean asyncDispatch;
     protected boolean sessionAsyncDispatch;
-    protected TaskRunner taskRunner;
 
     /**
      * Construct the Session

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java?rev=418285&r1=418284&r2=418285&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java
Fri Jun 30 06:48:30 2006
@@ -61,11 +61,16 @@
     }
 
     private void wakeup() {
-        if( taskRunner!=null && !dispatchedBySessionPool && hasUncomsumedMessages()
) {
-            try {
-                taskRunner.wakeup();
-            } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
+        if( !dispatchedBySessionPool && hasUncomsumedMessages() ) {
+            if( taskRunner!=null ) {
+                try {
+                    taskRunner.wakeup();
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+            } else {
+                while( iterate() )
+                    ;
             }
         }
     }
@@ -79,12 +84,6 @@
         return !messageQueue.isClosed() && messageQueue.isRunning() && !messageQueue.isEmpty();
     }
 
-    /**
-     * implementation of Runnable
-     */
-    public void run() {
-    }
-    
     void dispatch(MessageDispatch message){
 
         // TODO  - we should use a Map for this indexed by consumerId
@@ -101,7 +100,9 @@
     synchronized void start() {
         if( !messageQueue.isRunning() ) {
             messageQueue.start();
-            taskRunner = ActiveMQConnection.SESSION_TASK_RUNNER.createTaskRunner(this, "ActiveMQ
Session: "+session.getSessionId());
+            if( session.isSessionAsyncDispatch() || dispatchedBySessionPool ) {
+                taskRunner = ActiveMQConnection.SESSION_TASK_RUNNER.createTaskRunner(this,
"ActiveMQ Session: "+session.getSessionId());
+            }
             wakeup();
         }
     }
@@ -110,7 +111,10 @@
         try {
             if( messageQueue.isRunning() ) {
                 messageQueue.stop();
-                taskRunner.shutdown();
+                if( taskRunner!=null ) {
+                    taskRunner.shutdown();
+                    taskRunner=null;
+                }
             }
         } catch (InterruptedException e) {
             throw JMSExceptionSupport.create(e);
@@ -147,7 +151,7 @@
             return false;
         } else {
             dispatch(message);
-            return messageQueue.isRunning();
+            return !messageQueue.isEmpty();
         }
     }
 



Mime
View raw message