Search in sources :

Example 1 with JobException

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);
    }
}
Also used : JobException(com.swiftmq.swiftlet.scheduler.JobException) Entity(com.swiftmq.mgmt.Entity) Property(com.swiftmq.mgmt.Property) JobException(com.swiftmq.swiftlet.scheduler.JobException)

Example 2 with JobException

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);
    }
}
Also used : JobException(com.swiftmq.swiftlet.scheduler.JobException) Entity(com.swiftmq.mgmt.Entity) Property(com.swiftmq.mgmt.Property) JobException(com.swiftmq.swiftlet.scheduler.JobException)

Example 3 with JobException

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 + " ...");
}
Also used : JobException(com.swiftmq.swiftlet.scheduler.JobException) Semaphore(com.swiftmq.tools.concurrent.Semaphore) StartShrink(com.swiftmq.impl.store.standard.cache.po.StartShrink) JobException(com.swiftmq.swiftlet.scheduler.JobException)

Example 4 with JobException

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);
}
Also used : JobException(com.swiftmq.swiftlet.scheduler.JobException) JobException(com.swiftmq.swiftlet.scheduler.JobException)

Example 5 with JobException

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");
}
Also used : JobException(com.swiftmq.swiftlet.scheduler.JobException) AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) QueueException(com.swiftmq.swiftlet.queue.QueueException) QueueException(com.swiftmq.swiftlet.queue.QueueException) JobException(com.swiftmq.swiftlet.scheduler.JobException)

Aggregations

JobException (com.swiftmq.swiftlet.scheduler.JobException)11 MessageImpl (com.swiftmq.jms.MessageImpl)2 Entity (com.swiftmq.mgmt.Entity)2 Property (com.swiftmq.mgmt.Property)2 MessageSelector (com.swiftmq.ms.MessageSelector)2 AbstractQueue (com.swiftmq.swiftlet.queue.AbstractQueue)2 Semaphore (com.swiftmq.tools.concurrent.Semaphore)2 InvalidSelectorException (javax.jms.InvalidSelectorException)2 StartBackup (com.swiftmq.impl.store.standard.backup.po.StartBackup)1 StartShrink (com.swiftmq.impl.store.standard.cache.po.StartShrink)1 QueueImpl (com.swiftmq.jms.QueueImpl)1 QueueException (com.swiftmq.swiftlet.queue.QueueException)1 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1 List (java.util.List)1