Search in sources :

Example 6 with AbstractQueue

use of com.swiftmq.swiftlet.queue.AbstractQueue in project swiftmq-ce by iitsoftware.

the class ClusteredQueue method createPushTransaction.

public Object createPushTransaction() throws QueueException {
    ClusteredTransactionId txId = null;
    if (dispatchPolicy.isMessageBasedDispatch()) {
        txId = new ClusteredTransactionId(ctx, true);
    } else {
        String queueName = dispatchPolicy.getNextSendQueue();
        if (ctx.queueSpace.enabled)
            ctx.queueSpace.trace(getQueueName(), toString() + "/createPushTransaction, nextSendQueue=" + queueName);
        if (queueName == null)
            throw new QueueException("Unable to select a physical destination queue for this clustered queue!");
        AbstractQueue queue = ctx.queueManager.getQueueForInternalUse(queueName, true);
        txId = new ClusteredTransactionId(ctx, queue, queue.createPushTransaction(), new QueueImpl(queueName));
    }
    return txId;
}
Also used : AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) QueueException(com.swiftmq.swiftlet.queue.QueueException) QueueImpl(com.swiftmq.jms.QueueImpl)

Example 7 with AbstractQueue

use of com.swiftmq.swiftlet.queue.AbstractQueue in project swiftmq-ce by iitsoftware.

the class ClusteredTransactionId method putMessage.

public void putMessage(String queueName, MessageImpl message) throws Exception {
    Entry entry = queueMap.get(queueName);
    if (entry == null) {
        AbstractQueue abstractQueue = ctx.queueManager.getQueueForInternalUse(queueName);
        QueueImpl destination = new QueueImpl(queueName);
        Object transaction = abstractQueue.createPushTransaction();
        entry = new Entry(abstractQueue, destination, transaction);
        queueMap.put(queueName, entry);
    }
    message.setJMSDestination(entry.destination);
    message.setSourceRouter(null);
    message.setDestRouter(null);
    message.setDestQueue(queueName);
    entry.abstractQueue.putMessage(entry.transaction, message);
}
Also used : AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) QueueImpl(com.swiftmq.jms.QueueImpl)

Example 8 with AbstractQueue

use of com.swiftmq.swiftlet.queue.AbstractQueue 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)

Example 9 with AbstractQueue

use of com.swiftmq.swiftlet.queue.AbstractQueue in project swiftmq-ce by iitsoftware.

the class QueueResetJob 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 (LikeComparator.compare(names[i], predicate, '\\')) {
                    AbstractQueue queue = ctx.queueManager.getQueueForInternalUse(names[i]);
                    if (queue != null) {
                        if (ctx.traceSpace.enabled)
                            ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/reset: " + names[i]);
                        queue.resetCounters();
                    }
                }
                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) JobException(com.swiftmq.swiftlet.scheduler.JobException)

Example 10 with AbstractQueue

use of com.swiftmq.swiftlet.queue.AbstractQueue in project swiftmq-ce by iitsoftware.

the class QueueWireTapInput method start.

@Override
public void start() throws Exception {
    if (selector != null) {
        messageSelector = new MessageSelector(selector);
        messageSelector.compile();
    }
    queue = new ArrayBlockingQueue<MessageImpl>(bufferSize);
    AbstractQueue queue = ctx.ctx.queueManager.getQueueForInternalUse(destinationName);
    if (queue == null)
        throw new Exception("Queue '" + destinationName + "' is undefined!");
    queue.addWireTapSubscriber(name, this);
    started = true;
}
Also used : AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) MessageSelector(com.swiftmq.ms.MessageSelector) MessageImpl(com.swiftmq.jms.MessageImpl) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Aggregations

AbstractQueue (com.swiftmq.swiftlet.queue.AbstractQueue)19 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)4 XAException (javax.transaction.xa.XAException)4 QueueException (com.swiftmq.swiftlet.queue.QueueException)3 QueueImpl (com.swiftmq.jms.QueueImpl)2 EntityAddException (com.swiftmq.mgmt.EntityAddException)2 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)2 MessageSelector (com.swiftmq.ms.MessageSelector)2 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)2 QueueTransaction (com.swiftmq.swiftlet.queue.QueueTransaction)2 JobException (com.swiftmq.swiftlet.scheduler.JobException)2 Iterator (java.util.Iterator)2 QueueMetricImpl (com.swiftmq.impl.queue.standard.cluster.v700.QueueMetricImpl)1 BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)1 MessageImpl (com.swiftmq.jms.MessageImpl)1 XidImpl (com.swiftmq.jms.XidImpl)1 PropertyChangeException (com.swiftmq.mgmt.PropertyChangeException)1 SwiftletException (com.swiftmq.swiftlet.SwiftletException)1 AuthenticationException (com.swiftmq.swiftlet.auth.AuthenticationException)1 MessageIndex (com.swiftmq.swiftlet.queue.MessageIndex)1