use of org.apache.activemq.artemis.utils.FutureLatch in project activemq-artemis by apache.
the class BridgeImpl method flushExecutor.
@Override
public void flushExecutor() {
// Wait for any create objects runnable to complete
FutureLatch future = new FutureLatch();
executor.execute(future);
boolean ok = future.await(10000);
if (!ok) {
ActiveMQServerLogger.LOGGER.timedOutWaitingToStopBridge();
}
}
use of org.apache.activemq.artemis.utils.FutureLatch in project activemq-artemis by apache.
the class ServerConsumerImpl method setTransferring.
@Override
public void setTransferring(final boolean transferring) {
synchronized (lock) {
// This is to make sure that the delivery process has finished any pending delivery
// otherwise a message may sneak in on the client while we are trying to stop the consumer
boolean locked = lockDelivery();
try {
this.transferring = transferring;
} finally {
if (locked) {
lockDelivery.writeLock().unlock();
}
}
}
// Outside the lock
if (transferring) {
// And we must wait for any force delivery to be executed - this is executed async so we add a future to the
// executor and
// wait for it to complete
FutureLatch future = new FutureLatch();
messageQueue.getExecutor().execute(future);
boolean ok = future.await(10000);
if (!ok) {
ActiveMQServerLogger.LOGGER.errorTransferringConsumer();
}
}
if (!transferring) {
promptDelivery();
}
}
use of org.apache.activemq.artemis.utils.FutureLatch in project activemq-artemis by apache.
the class ClientConsumerImpl method waitForOnMessageToComplete.
private void waitForOnMessageToComplete(boolean waitForOnMessage) {
if (handler == null) {
return;
}
if (!waitForOnMessage || Thread.currentThread() == onMessageThread) {
// If called from inside onMessage then return immediately - otherwise would block
return;
}
FutureLatch future = new FutureLatch();
sessionExecutor.execute(future);
boolean ok = future.await(ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS);
if (!ok) {
ActiveMQClientLogger.LOGGER.timeOutWaitingForProcessing();
}
}
use of org.apache.activemq.artemis.utils.FutureLatch in project activemq-artemis by apache.
the class PagingStoreImpl method flushExecutors.
@Override
public void flushExecutors() {
cursorProvider.flushExecutors();
FutureLatch future = new FutureLatch();
executor.execute(future);
if (!future.await(60000)) {
ActiveMQServerLogger.LOGGER.pageStoreTimeout(address);
}
}
use of org.apache.activemq.artemis.utils.FutureLatch in project activemq-artemis by apache.
the class QueueImplTest method awaitExecution.
private void awaitExecution() {
FutureLatch future = new FutureLatch();
executor.execute(future);
future.await(10000);
}
Aggregations