Search in sources :

Example 21 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class SessionHandler method close.

public void close() {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", close ...");
    closeLock.lock();
    if (closeInProgress) {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", close in progress, return");
        return;
    }
    closeInProgress = true;
    closeLock.unlock();
    sessionDisabled = false;
    Semaphore sem = new Semaphore();
    dispatch(new POCloseSession(sem));
    sem.waitHere();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", close done");
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 22 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class AMQPHandler method close.

public void close() {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", close ...");
    closeLock.lock();
    if (closeInProgress) {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", close in progress, return");
        return;
    }
    closeInProgress = true;
    closeLock.unlock();
    Semaphore sem = new Semaphore();
    dispatch(new POClose(sem));
    sem.waitHere();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", close done");
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 23 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class ServerLink method close.

public void close() {
    closed = true;
    if (waitingPO != null) {
        waitingPO.setSuccess(false);
        waitingPO.setException("ServerLink closed");
        Semaphore sem = waitingPO.getSemaphore();
        if (sem != null)
            sem.notifySingleWaiter();
        waitingPO = null;
    }
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 24 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class DefaultScheduler method close.

public void close() {
    // debug    ctx.timerSwiftlet.removeTimerListener(tl);
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/close ...");
    synchronized (this) {
        if (closed)
            return;
        for (Iterator iter = connections.iterator(); iter.hasNext(); ) {
            ConnectionEntry entry = (ConnectionEntry) iter.next();
            iter.remove();
            connectionRemoved(entry.getRoutingConnection());
        }
    }
    Semaphore sem = new Semaphore();
    enqueueClose(new POCloseObject(null, sem));
    sem.waitHere();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/close done");
}
Also used : POCloseObject(com.swiftmq.impl.routing.single.schedule.po.POCloseObject) Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 25 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class Consumer method consume.

public void consume() {
    sem = new Semaphore();
    sem.waitHere();
    if (exception != null)
        failFast("failed: " + exception);
    try {
        verifier.verify();
    } catch (Exception e) {
        failFast("failed: " + e);
    }
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Aggregations

Semaphore (com.swiftmq.tools.concurrent.Semaphore)149 MsgNoVerifier (jms.base.MsgNoVerifier)18 IOException (java.io.IOException)8 SwiftletException (com.swiftmq.swiftlet.SwiftletException)6 ArrayList (java.util.ArrayList)6 CommitLogRecord (com.swiftmq.impl.store.standard.log.CommitLogRecord)5 DataStreamOutputStream (com.swiftmq.tools.util.DataStreamOutputStream)5 List (java.util.List)5 StartBackup (com.swiftmq.impl.store.standard.backup.po.StartBackup)2 StartShrink (com.swiftmq.impl.store.standard.cache.po.StartShrink)2 UnknownHostException (java.net.UnknownHostException)2 POAttachDurableConsumer (com.swiftmq.amqp.v100.client.po.POAttachDurableConsumer)1 POAuthenticate (com.swiftmq.amqp.v100.client.po.POAuthenticate)1 POCloseLink (com.swiftmq.amqp.v100.client.po.POCloseLink)1 POOpen (com.swiftmq.amqp.v100.client.po.POOpen)1 POProtocolRequest (com.swiftmq.amqp.v100.client.po.POProtocolRequest)1 POSendClose (com.swiftmq.amqp.v100.client.po.POSendClose)1 POSendMessage (com.swiftmq.amqp.v100.client.po.POSendMessage)1 AddressString (com.swiftmq.amqp.v100.generated.messaging.message_format.AddressString)1 Header (com.swiftmq.amqp.v100.generated.messaging.message_format.Header)1