use of com.swiftmq.swiftlet.queue.event.QueueManagerEvent in project swiftmq-ce by iitsoftware.
the class QueueManagerImpl method startQueue.
/**
* @param queue
* @throws QueueException
*/
private void startQueue(ActiveQueue queue) throws QueueException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startQueue: starting queue '" + queue.getAbstractQueue().getQueueName() + "'");
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' fireQueueManagerEvent, method: queueStartInitiated");
fireQueueManagerEvent(queue.getAbstractQueue().getQueueName(), "queueStartInitiated", new QueueManagerEvent(this, queue.getAbstractQueue().getQueueName()));
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' queue.getAbstractQueue().startQueue()");
queue.getAbstractQueue().startQueue();
queue.setStartupTime(System.currentTimeMillis());
Entity queueEntity = ((ActiveQueueImpl) queue).getQueueEntity();
if (queueEntity != null) {
Property prop = queueEntity.getProperty(PROP_CLEANUP_INTERVAL);
CleanupListener l = new CleanupListener((ActiveQueueImpl) queue);
prop.addPropertyWatchListener(l);
((ActiveQueueImpl) queue).setWatchListener(l);
}
long interval = queue.getAbstractQueue().getCleanUpInterval();
if (interval > 0) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' addTimerListener for interval " + interval);
ctx.timerSwiftlet.addTimerListener(interval, queue);
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' fireQueueManagerEvent, method: queueStarted");
fireQueueManagerEvent(queue.getAbstractQueue().getQueueName(), "queueStarted", new QueueManagerEvent(this, queue.getAbstractQueue().getQueueName()));
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' started");
if (ctx.jndiSwiftlet != null) {
String name = queue.getAbstractQueue().getQueueName();
try {
SwiftUtilities.verifyQueueName(name);
registerJNDI(name, new QueueImpl(name));
} catch (Exception ignored) {
}
}
}
use of com.swiftmq.swiftlet.queue.event.QueueManagerEvent in project swiftmq-ce by iitsoftware.
the class QueueManagerImpl method stopQueue.
/**
* @param queue
* @throws QueueException
*/
private void stopQueue(ActiveQueue queue) throws QueueException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopQueue: stopping queue '" + queue.getAbstractQueue().getQueueName() + "'");
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' fireQueueManagerEvent, method: queueStopInitiated");
fireQueueManagerEvent(queue.getAbstractQueue().getQueueName(), "queueStopInitiated", new QueueManagerEvent(this, queue.getAbstractQueue().getQueueName()));
long interval = queue.getAbstractQueue().getCleanUpInterval();
if (interval > 0) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' removeTimerListener for interval " + interval);
ctx.timerSwiftlet.removeTimerListener(queue);
}
Entity queueEntity = ((ActiveQueueImpl) queue).getQueueEntity();
if (queueEntity != null) {
Property prop = queueEntity.getProperty(PROP_CLEANUP_INTERVAL);
prop.removePropertyWatchListener(((ActiveQueueImpl) queue).getWatchListener());
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' queue.getAbstractQueue().stopQueue()");
queue.getAbstractQueue().stopQueue();
queue.setStartupTime(-1);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' fireQueueManagerEvent, method: queueStopped");
fireQueueManagerEvent(queue.getAbstractQueue().getQueueName(), "queueStopped", new QueueManagerEvent(this, queue.getAbstractQueue().getQueueName()));
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopQueue: queue '" + queue.getAbstractQueue().getQueueName() + "' stopped");
if (ctx.jndiSwiftlet != null) {
String name = queue.getAbstractQueue().getQueueName();
try {
SwiftUtilities.verifyQueueName(name);
ctx.jndiSwiftlet.deregisterJNDIObject(name);
unregisterJNDIAlias(stripLocalName(name));
} catch (Exception ignored) {
}
}
}
Aggregations