Search in sources :

Example 11 with DataStreamOutputStream

use of com.swiftmq.tools.util.DataStreamOutputStream in project swiftmq-client by iitsoftware.

the class Connector method visit.

public void visit(POReconnect po) {
    if (debug)
        System.out.println(toString() + ", visit, po=" + po + " ...");
    if (closed) {
        if (debug)
            System.out.println(toString() + ", visit, po=" + po + ", closed, return");
        if (po.getSemaphore() != null)
            po.getSemaphore().notifySingleWaiter();
        return;
    }
    if (reconnectInProgress && !po.isInternalRetry()) {
        if (debug)
            System.out.println(toString() + ", visit, po=" + po + ", reconnect already in progress");
        if (po.getSemaphore() != null)
            po.getSemaphore().notifySingleWaiter();
    } else {
        reconnectInProgress = true;
        recreateStarted = false;
        sem = po.getSemaphore();
        recreatableConnection = po.getRecreatableConnection();
        if (!po.isInternalRetry())
            recreatableConnection.prepareForReconnect();
        connection = reconnector.getConnection();
        if (connection != null) {
            if (debug)
                System.out.println(toString() + ", visit, po=" + po + ", connection=" + connection);
            connection.setInboundHandler(this);
            connection.setExceptionHandler(this);
            outStream = new DataStreamOutputStream(connection.getOutputStream());
            try {
                connection.start();
                dispatch(new POVersionRequest());
            } catch (Exception e) {
                if (debug)
                    System.out.println(toString() + ", visit, po=" + po + ", exception connection.start()=" + e);
                reconnector.invalidateConnection();
                connection = null;
                dispatch(new POHandover());
            }
        } else
            dispatch(new POHandover());
    }
    if (debug)
        System.out.println(toString() + ", visit, po=" + po + " done");
}
Also used : DataStreamOutputStream(com.swiftmq.tools.util.DataStreamOutputStream) IOException(java.io.IOException)

Example 12 with DataStreamOutputStream

use of com.swiftmq.tools.util.DataStreamOutputStream in project swiftmq-ce by iitsoftware.

the class VersionSelector method sendReply.

private void sendReply(SMQPVersionReply reply) throws IOException {
    DataStreamOutputStream dos = new DataStreamOutputStream(connection.getOutputStream());
    Dumpalizer.dump(dos, reply);
    dos.flush();
    if (!reply.isOk()) {
        ctx.timerSwiftlet.addInstantTimerListener(10000, new TimerListener() {

            public void performTimeAction() {
                ctx.networkSwiftlet.getConnectionManager().removeConnection(connection);
            }
        });
    }
}
Also used : DataStreamOutputStream(com.swiftmq.tools.util.DataStreamOutputStream) TimerListener(com.swiftmq.swiftlet.timer.event.TimerListener)

Aggregations

DataStreamOutputStream (com.swiftmq.tools.util.DataStreamOutputStream)12 Semaphore (com.swiftmq.tools.concurrent.Semaphore)5 IOException (java.io.IOException)5 JMSSecurityException (javax.jms.JMSSecurityException)3 InvalidVersionException (com.swiftmq.jms.InvalidVersionException)2 TimerListener (com.swiftmq.swiftlet.timer.event.TimerListener)2 POAuthenticate (com.swiftmq.amqp.v100.client.po.POAuthenticate)1 POOpen (com.swiftmq.amqp.v100.client.po.POOpen)1 POProtocolRequest (com.swiftmq.amqp.v100.client.po.POProtocolRequest)1 SocketFactory2 (com.swiftmq.net.SocketFactory2)1 BlockingConnection (com.swiftmq.net.client.BlockingConnection)1 ProtocolInputHandler (com.swiftmq.net.protocol.ProtocolInputHandler)1 ProtocolOutputHandler (com.swiftmq.net.protocol.ProtocolOutputHandler)1 RawOutputHandler (com.swiftmq.net.protocol.raw.RawOutputHandler)1 POObject (com.swiftmq.tools.pipeline.POObject)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1