mirror of https://github.com/apache/activemq.git
If sessionAsyncDispatch==false we do not need to create a session thread.
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@418285 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2f7da7fa9b
commit
686db796b9
|
@ -72,7 +72,6 @@ import org.apache.activemq.management.JMSSessionStatsImpl;
|
|||
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 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
|
|||
protected boolean closed;
|
||||
protected boolean asyncDispatch;
|
||||
protected boolean sessionAsyncDispatch;
|
||||
protected TaskRunner taskRunner;
|
||||
|
||||
/**
|
||||
* Construct the Session
|
||||
|
|
|
@ -61,12 +61,17 @@ public class ActiveMQSessionExecutor implements Task {
|
|||
}
|
||||
|
||||
private void wakeup() {
|
||||
if( taskRunner!=null && !dispatchedBySessionPool && hasUncomsumedMessages() ) {
|
||||
if( !dispatchedBySessionPool && hasUncomsumedMessages() ) {
|
||||
if( taskRunner!=null ) {
|
||||
try {
|
||||
taskRunner.wakeup();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
} else {
|
||||
while( iterate() )
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,12 +84,6 @@ public class ActiveMQSessionExecutor implements Task {
|
|||
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 @@ public class ActiveMQSessionExecutor implements Task {
|
|||
synchronized void start() {
|
||||
if( !messageQueue.isRunning() ) {
|
||||
messageQueue.start();
|
||||
if( session.isSessionAsyncDispatch() || dispatchedBySessionPool ) {
|
||||
taskRunner = ActiveMQConnection.SESSION_TASK_RUNNER.createTaskRunner(this, "ActiveMQ Session: "+session.getSessionId());
|
||||
}
|
||||
wakeup();
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +111,10 @@ public class ActiveMQSessionExecutor implements Task {
|
|||
try {
|
||||
if( messageQueue.isRunning() ) {
|
||||
messageQueue.stop();
|
||||
if( taskRunner!=null ) {
|
||||
taskRunner.shutdown();
|
||||
taskRunner=null;
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw JMSExceptionSupport.create(e);
|
||||
|
@ -147,7 +151,7 @@ public class ActiveMQSessionExecutor implements Task {
|
|||
return false;
|
||||
} else {
|
||||
dispatch(message);
|
||||
return messageQueue.isRunning();
|
||||
return !messageQueue.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue