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);
}
});
}
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();
}
}
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();
}
}
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();
}
});
}
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;
}
}
Aggregations