mirror of https://github.com/apache/activemq.git
AMQ-6674 Ensure timely shutdown of the connection executor
Don't wait for next idle check or other scheduled tasks to run before shutdown can proceed.
This commit is contained in:
parent
154ff81eee
commit
4f7c9ec811
|
@ -25,8 +25,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -73,7 +73,7 @@ public class AmqpConnection extends AmqpAbstractResource<Connection> implements
|
|||
public static final long DEFAULT_CLOSE_TIMEOUT = 30000;
|
||||
public static final long DEFAULT_DRAIN_TIMEOUT = 60000;
|
||||
|
||||
private final ScheduledExecutorService serializer;
|
||||
private ScheduledThreadPoolExecutor serializer;
|
||||
private final AtomicBoolean closed = new AtomicBoolean();
|
||||
private final AtomicBoolean connected = new AtomicBoolean();
|
||||
private final AtomicLong sessionIdGenerator = new AtomicLong();
|
||||
|
@ -116,7 +116,7 @@ public class AmqpConnection extends AmqpAbstractResource<Connection> implements
|
|||
this.connectionId = CONNECTION_ID_GENERATOR.generateId();
|
||||
this.remoteURI = transport.getRemoteLocation();
|
||||
|
||||
this.serializer = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
|
||||
this.serializer = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable runner) {
|
||||
|
@ -127,6 +127,10 @@ public class AmqpConnection extends AmqpAbstractResource<Connection> implements
|
|||
}
|
||||
});
|
||||
|
||||
// Ensure timely shutdown
|
||||
this.serializer.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
|
||||
this.serializer.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
|
||||
|
||||
this.transport.setTransportListener(this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue