26
26
import java .util .Map ;
27
27
import java .util .concurrent .ConcurrentHashMap ;
28
28
import java .util .concurrent .ConcurrentLinkedDeque ;
29
+ import java .util .concurrent .ConcurrentLinkedQueue ;
29
30
import java .util .concurrent .CountDownLatch ;
30
31
import java .util .concurrent .ExecutionException ;
31
32
import java .util .concurrent .Executor ;
72
73
import javax .jms .TopicSession ;
73
74
import javax .jms .TopicSubscriber ;
74
75
75
- import io .netty .util .internal .PlatformDependent ;
76
76
import org .apache .qpid .jms .exceptions .JmsConnectionFailedException ;
77
77
import org .apache .qpid .jms .exceptions .JmsExceptionSupport ;
78
78
import org .apache .qpid .jms .message .JmsInboundMessageDispatch ;
@@ -127,7 +127,7 @@ public class JmsSession implements AutoCloseable, Session, QueueSession, TopicSe
127
127
private final JmsSessionInfo sessionInfo ;
128
128
private final ReentrantLock sendLock = new ReentrantLock ();
129
129
private volatile ThreadPoolExecutor deliveryExecutor ;
130
- private volatile ThreadPoolExecutor completionExcecutor ;
130
+ private volatile ExecutorService completionExecutor ;
131
131
private AtomicReference <Thread > deliveryThread = new AtomicReference <Thread >();
132
132
private boolean deliveryThreadCheckEnabled = true ;
133
133
private volatile Thread completionThread = null ;
@@ -139,7 +139,7 @@ public class JmsSession implements AutoCloseable, Session, QueueSession, TopicSe
139
139
private boolean sessionRecovered ;
140
140
private final AtomicReference <Throwable > failureCause = new AtomicReference <>();
141
141
private final Deque <SendCompletion > asyncSendQueue = new ConcurrentLinkedDeque <SendCompletion >();
142
- private final java . util . Queue <Runnable > completionTasks = PlatformDependent . newMpscQueue ();
142
+ private final ConcurrentLinkedQueue <Runnable > completionTasks = new ConcurrentLinkedQueue <> ();
143
143
144
144
protected JmsSession (JmsConnection connection , JmsSessionId sessionId , int acknowledgementMode ) throws JMSException {
145
145
this .connection = connection ;
@@ -222,7 +222,7 @@ private void processCompletions() {
222
222
if (!processCompletion .compareAndSet (false , true )) {
223
223
return ;
224
224
}
225
- if (! connection .isUseConnectionCompletionHandler () ) {
225
+ if (connection .getCompletionExecutorService () == null ) {
226
226
// an exclusive per-session executor doesn't need to guarantee fair completion processing
227
227
// and can just keep on processing completion on this same thread
228
228
continue ;
@@ -428,11 +428,11 @@ protected boolean shutdown(Throwable cause) throws JMSException {
428
428
cause = new JMSException ("Session closed remotely before message transfer result was notified" );
429
429
}
430
430
asyncProcessCompletion (new FailOrCompleteAsyncCompletionsTask (JmsExceptionSupport .create (cause )), true );
431
- if (! connection .isUseConnectionCompletionHandler () ) {
431
+ if (connection .getCompletionExecutorService () == null ) {
432
432
getCompletionExecutor ().shutdown ();
433
433
}
434
434
}
435
- if (connection .isUseConnectionCompletionHandler () ) {
435
+ if (connection .getCompletionExecutorService () != null ) {
436
436
final CountDownLatch completed = new CountDownLatch (1 );
437
437
try {
438
438
asyncProcessCompletion (completed ::countDown , true );
@@ -1260,13 +1260,13 @@ Executor getDispatcherExecutor() {
1260
1260
}
1261
1261
1262
1262
private ExecutorService getCompletionExecutor () {
1263
- ThreadPoolExecutor exec = completionExcecutor ;
1263
+ ExecutorService exec = completionExecutor ;
1264
1264
if (exec == null ) {
1265
1265
synchronized (sessionInfo ) {
1266
- exec = completionExcecutor ;
1266
+ exec = completionExecutor ;
1267
1267
if (exec == null ) {
1268
- if (connection .isUseConnectionCompletionHandler () ) {
1269
- exec = connection .executor ;
1268
+ if (connection .getCompletionExecutorService () != null ) {
1269
+ exec = connection .getCompletionExecutorService (). ref () ;
1270
1270
} else {
1271
1271
exec = createExecutor ("completion dispatcher" , null );
1272
1272
}
@@ -1280,7 +1280,7 @@ private ExecutorService getCompletionExecutor() {
1280
1280
LOG .trace ("Completion Executor starter task failed: {}" , e .getMessage ());
1281
1281
}
1282
1282
1283
- completionExcecutor = exec ;
1283
+ completionExecutor = exec ;
1284
1284
}
1285
1285
}
1286
1286
}
0 commit comments