use of com.swiftmq.swiftlet.scheduler.JobException in project swiftmq-ce by iitsoftware.
the class StreamsJob method doAction.
private void doAction(boolean b) throws JobException {
Entity domain = ctx.root.getEntity("domains").getEntity(domainName);
if (domain == null)
throw new JobException("Domain '" + domainName + "' is undefined!", null, false);
Entity pkg = domain.getEntity("packages").getEntity(packageName);
if (pkg == null)
throw new JobException("Package '" + packageName + "' is undefined!", null, false);
Entity entity = pkg.getEntity("streams").getEntity(name);
if (entity == null)
throw new JobException("Stream '" + name + "' is undefined!", null, false);
Property prop = entity.getProperty("enabled");
boolean enabled = ((Boolean) prop.getValue()).booleanValue();
try {
if (enabled != b)
prop.setValue(new Boolean(b));
} catch (Exception e) {
throw new JobException(e.getMessage(), e, false);
}
}
use of com.swiftmq.swiftlet.scheduler.JobException in project swiftmq-ce by iitsoftware.
the class RoutingConnectorJob method doAction.
private void doAction(boolean b) throws JobException {
Entity entity = ctx.root.getEntity("connectors").getEntity(name);
if (entity == null)
throw new JobException("Routing Connector '" + name + "' is undefined!", null, false);
Property prop = entity.getProperty("enabled");
boolean enabled = ((Boolean) prop.getValue()).booleanValue();
try {
if (enabled != b)
prop.setValue(new Boolean(b));
} catch (Exception e) {
throw new JobException(e.getMessage(), e, false);
}
}
use of com.swiftmq.swiftlet.scheduler.JobException in project swiftmq-ce by iitsoftware.
the class ShrinkJob method start.
public synchronized void start(Properties properties, JobTerminationListener jobTerminationListener) throws JobException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/start, properties=" + properties + " ...");
this.jobTerminationListener = jobTerminationListener;
this.properties = properties;
Semaphore sem = new Semaphore();
StartShrink po = new StartShrink(sem);
ctx.shrinkProcessor.enqueue(po);
sem.waitHere();
if (po.isSuccess())
jobTerminationListener.jobTerminated();
else
jobTerminationListener.jobTerminated(new JobException(po.getException(), new Exception(po.getException()), false));
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/start, properties=" + properties + " ...");
}
use of com.swiftmq.swiftlet.scheduler.JobException in project swiftmq-ce by iitsoftware.
the class QueueCleanupDLQJob method start.
public void start(Properties properties, JobTerminationListener jobTerminationListener) throws JobException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/start, properties=" + properties + " ...");
this.properties = properties;
StringBuffer termMsg = new StringBuffer();
try {
String predicate = properties.getProperty("Queue Name Predicate");
String[] names = ctx.queueManager.getDefinedQueueNames();
if (names != null) {
for (int i = 0; i < names.length; i++) {
if (!names[i].startsWith("tpc$")) {
if (LikeComparator.compare(names[i], predicate, '\\')) {
if (termMsg.length() > 0)
termMsg.append(", ");
termMsg.append(names[i]);
termMsg.append("=");
try {
termMsg.append(cleanupQueue(names[i]));
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/exception=" + e);
termMsg.append(e.toString());
}
}
}
if (stopCalled)
break;
}
}
} catch (Exception e) {
closeResources();
throw new JobException(e.toString(), e, false);
}
closeResources();
jobTerminationListener.jobTerminated(termMsg.toString());
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/start, properties=" + properties + " done, " + termMsg);
}
use of com.swiftmq.swiftlet.scheduler.JobException in project swiftmq-ce by iitsoftware.
the class QueueCleanupJob method start.
public void start(Properties properties, JobTerminationListener jobTerminationListener) throws JobException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/start, properties=" + properties + " ...");
this.properties = properties;
if (stopCalled) {
terminate();
return;
}
try {
String predicate = properties.getProperty("Queue Name Predicate");
String[] names = ctx.queueManager.getDefinedQueueNames();
if (names != null) {
for (int i = 0; i < names.length; i++) {
if (!names[i].startsWith("tpc$")) {
if (LikeComparator.compare(names[i], predicate, '\\')) {
try {
AbstractQueue queue = ctx.queueManager.getQueueForInternalUse(names[i]);
if (queue != null) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/cleanup: " + names[i]);
queue.cleanUpExpiredMessages();
}
} catch (QueueException e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/cleanup: " + names[i] + ", exception=" + e);
}
}
}
if (stopCalled)
break;
}
}
} catch (Exception e) {
terminate();
throw new JobException(e.toString(), e, false);
}
terminate();
jobTerminationListener.jobTerminated();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/start, properties=" + properties + " done");
}
Aggregations