Search in sources :

Example 31 with Semaphore

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

the class SessionImpl method close.

public void close() throws JMSException {
    if (closed)
        return;
    if (messageListener == null && !isSessionStarted()) {
        _close();
        return;
    }
    CloseSession request = new CloseSession();
    request._sem = new Semaphore();
    if (messageListener == null)
        serviceRequest(request);
    else {
        addMessageChunk(request);
    }
    request._sem.waitHere(5000);
    if (!request._sem.isNotified())
        _close();
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 32 with Semaphore

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

the class MessageConsumerImpl method close.

public void close() throws JMSException {
    if (closed)
        return;
    if (!mySession.isSessionStarted()) {
        close(null);
        return;
    }
    CloseConsumer request = new CloseConsumer(consumerId);
    request._sem = new Semaphore();
    mySession.serviceRequest(request);
    request._sem.waitHere();
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 33 with Semaphore

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

the class ConnectionImpl method reconnectAndWait.

private void reconnectAndWait() {
    if (reconnector.isDebug())
        System.out.println(toString() + ": initiate reconnect and wait ...");
    lastConnectionLost = System.currentTimeMillis();
    Semaphore sem = new Semaphore();
    POReconnect po = new POReconnect(sem, this);
    connector.dispatch(po);
    sem.waitHere();
    if (reconnector.isDebug())
        System.out.println(toString() + ": reconnect done, connection =" + connection);
}
Also used : POReconnect(com.swiftmq.jms.v610.po.POReconnect) Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 34 with Semaphore

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

the class ConnectionImpl method handOver.

public void handOver(com.swiftmq.net.client.Connection connection) {
    this.connection = connection;
    if (connection != null) {
        connectionId++;
        myHostname = connection.getLocalHostname();
        connection.setInboundHandler(this);
        connection.setExceptionHandler(this);
        outStream = new DataStreamOutputStream(connection.getOutputStream());
        if (connectionQueue != null) {
            connectionQueue.clear();
            connectionQueue.startQueue();
        }
        // Blocks new XA Requests
        setSessionBlockState(true);
        if (requestRegistry != null) {
            requestRegistry.setPaused(false);
            Semaphore retrySem = new Semaphore();
            requestRegistry.retryAllRequests(retrySem);
            retrySem.waitHere();
        }
        resetSessions(false);
        notifyReconnectListener();
        setSessionBlockState(false);
    }
}
Also used : DataStreamOutputStream(com.swiftmq.tools.util.DataStreamOutputStream) Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 35 with Semaphore

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

the class MessageConsumerImpl method close.

public void close() throws JMSException {
    if (closed)
        return;
    if (!mySession.isSessionStarted()) {
        close(null);
        return;
    }
    CloseConsumer request = new CloseConsumer(consumerId);
    request._sem = new Semaphore();
    mySession.serviceRequest(request);
    request._sem.waitHere();
}
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