Search in sources :

Example 1 with FutureLatch

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();
    }
}
Also used : FutureLatch(org.apache.activemq.artemis.utils.FutureLatch)

Example 2 with FutureLatch

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();
    }
}
Also used : FutureLatch(org.apache.activemq.artemis.utils.FutureLatch)

Example 3 with FutureLatch

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();
    }
}
Also used : FutureLatch(org.apache.activemq.artemis.utils.FutureLatch)

Example 4 with FutureLatch

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);
    }
}
Also used : FutureLatch(org.apache.activemq.artemis.utils.FutureLatch)

Example 5 with FutureLatch

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);
}
Also used : FutureLatch(org.apache.activemq.artemis.utils.FutureLatch)

Aggregations

FutureLatch (org.apache.activemq.artemis.utils.FutureLatch)8 ArrayList (java.util.ArrayList)1 ResourceException (javax.resource.ResourceException)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)1 ActiveMQNotConnectedException (org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException)1