Search in sources :

Example 1 with TimerListener

use of com.swiftmq.swiftlet.timer.event.TimerListener 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 TimerListener

use of com.swiftmq.swiftlet.timer.event.TimerListener in project swiftmq-ce by iitsoftware.

the class AtTimer method start.

@Override
public void start() throws Exception {
    timerListener = new TimerListener() {

        @Override
        public void performTimeAction() {
            ctx.streamProcessor.dispatch(new POTimer(null, AtTimer.this));
        }
    };
    ctx.ctx.timerSwiftlet.addInstantTimerListener(calcNextStart(), timerListener);
    try {
        usage.getProperty("started").setValue(new Boolean(true));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : POTimer(com.swiftmq.impl.streams.processor.po.POTimer) TimerListener(com.swiftmq.swiftlet.timer.event.TimerListener)

Example 3 with TimerListener

use of com.swiftmq.swiftlet.timer.event.TimerListener in project swiftmq-ce by iitsoftware.

the class IntervalTimer method start.

@Override
public void start() throws Exception {
    timerListener = new TimerListener() {

        @Override
        public void performTimeAction() {
            ctx.streamProcessor.dispatch(new POTimer(null, IntervalTimer.this));
        }
    };
    ctx.ctx.timerSwiftlet.addTimerListener(millis, timerListener);
    try {
        usage.getProperty("started").setValue(new Boolean(true));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : POTimer(com.swiftmq.impl.streams.processor.po.POTimer) TimerListener(com.swiftmq.swiftlet.timer.event.TimerListener)

Example 4 with TimerListener

use of com.swiftmq.swiftlet.timer.event.TimerListener in project swiftmq-ce by iitsoftware.

the class StreamProcessor method handleException.

private void handleException(POObject po, Exception e) {
    ctx.logStackTrace(e);
    po.setException(e.getMessage());
    po.setSuccess(false);
    ctx.rollbackTransactions();
    ctx.setLastException(e);
    ctx.stream.executeOnExceptionCallback();
    ctx.ctx.timerSwiftlet.addInstantTimerListener(100, new TimerListener() {

        @Override
        public void performTimeAction() {
            controller.restart();
        }
    });
}
Also used : TimerListener(com.swiftmq.swiftlet.timer.event.TimerListener)

Example 5 with TimerListener

use of com.swiftmq.swiftlet.timer.event.TimerListener in project swiftmq-ce by iitsoftware.

the class OutboundWriter method writeObject.

public void writeObject(Dumpable obj) {
    if (closed)
        return;
    if (traceSpace.enabled)
        traceSpace.trace("smqp", "write object: " + obj);
    try {
        Dumpalizer.dump(outStream, obj);
        outStream.flush();
        if (obj.getDumpId() == SMQPFactory.DID_DISCONNECT_REP) {
            timerSwiftlet.addInstantTimerListener(10000, new TimerListener() {

                public void performTimeAction() {
                    networkSwiftlet.getConnectionManager().removeConnection(connection);
                    outboundQueue.close();
                    closed = true;
                }
            });
        }
    } catch (Exception e) {
        if (traceSpace.enabled)
            traceSpace.trace("smqp", "exception write object, exiting!: " + e);
        // closes the connection
        networkSwiftlet.getConnectionManager().removeConnection(connection);
        outboundQueue.close();
        closed = true;
    }
}
Also used : TimerListener(com.swiftmq.swiftlet.timer.event.TimerListener)

Aggregations

TimerListener (com.swiftmq.swiftlet.timer.event.TimerListener)21 POTimer (com.swiftmq.impl.streams.processor.po.POTimer)3 ChallengeResponseFactory (com.swiftmq.auth.ChallengeResponseFactory)2 RequestHandler (com.swiftmq.impl.routing.single.smqpr.RequestHandler)2 StartStageRequest (com.swiftmq.impl.routing.single.smqpr.StartStageRequest)2 Request (com.swiftmq.tools.requestreply.Request)2 DataStreamOutputStream (com.swiftmq.tools.util.DataStreamOutputStream)2 Milliseconds (com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds)1 AuthReplyRequest (com.swiftmq.impl.routing.single.smqpr.v400.AuthReplyRequest)1 AuthRequest (com.swiftmq.impl.routing.single.smqpr.v400.AuthRequest)1 ConnectReplyRequest (com.swiftmq.impl.routing.single.smqpr.v400.ConnectReplyRequest)1 AuthReplyRequest (com.swiftmq.impl.routing.single.smqpr.v942.AuthReplyRequest)1 AuthRequest (com.swiftmq.impl.routing.single.smqpr.v942.AuthRequest)1 ConnectReplyRequest (com.swiftmq.impl.routing.single.smqpr.v942.ConnectReplyRequest)1 MessageImpl (com.swiftmq.jms.MessageImpl)1 Entity (com.swiftmq.mgmt.Entity)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 JMSException (javax.jms.JMSException)1