Search in sources :

Example 1 with DataStreamOutputStream

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

the class VersionedConnection method sendAndClose.

private void sendAndClose(final Connection connection, ProtocolHeader rcvHeader, ProtocolHeader header) throws IOException {
    if (ctx.protSpace.enabled)
        ctx.protSpace.trace("amqp", toString() + "/SND: " + header);
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/wrong header received: " + rcvHeader + ", required: " + header + ", closing connection");
    ctx.logSwiftlet.logError(ctx.amqpSwiftlet.getName(), toString() + "/wrong header received: " + rcvHeader + ", required: " + header + ", closing connection");
    DataStreamOutputStream out = new DataStreamOutputStream(connection.getOutputStream());
    header.writeContent(out);
    out.flush();
    ctx.timerSwiftlet.addInstantTimerListener(500, 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)

Example 2 with DataStreamOutputStream

use of com.swiftmq.tools.util.DataStreamOutputStream 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 3 with DataStreamOutputStream

use of com.swiftmq.tools.util.DataStreamOutputStream 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 4 with DataStreamOutputStream

use of com.swiftmq.tools.util.DataStreamOutputStream 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 5 with DataStreamOutputStream

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

the class Exporter method store.

private void store(String queueName, XStream xStream, File outputDir, int nMsgs, MessageImpl message) throws Exception {
    String fn = "swiftmq_" + queueName + "_" + FMT.format(nMsgs);
    if (xStream != null) {
        File outFile = new File(outputDir, fn + ".xml");
        BufferedWriter bos = new BufferedWriter(new FileWriter(outFile));
        message.unfoldBuffers();
        xStream.toXML(message, bos);
        bos.flush();
        bos.close();
    } else {
        File outFile = new File(outputDir, fn + ".message");
        DataStreamOutputStream dos = new DataStreamOutputStream(new FileOutputStream(outFile));
        message.writeContent(dos);
        dos.flush();
        dos.close();
    }
}
Also used : FileWriter(java.io.FileWriter) FileOutputStream(java.io.FileOutputStream) DataStreamOutputStream(com.swiftmq.tools.util.DataStreamOutputStream) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

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