use of com.swiftmq.jms.QueueImpl 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.jms.QueueImpl 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;
}
use of com.swiftmq.jms.QueueImpl 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);
}
use of com.swiftmq.jms.QueueImpl in project swiftmq-ce by iitsoftware.
the class QueueMoverJob 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;
int cnt = 0;
String queueName = properties.getProperty("Source Queue");
if (!queueName.startsWith("tpc$")) {
MessageSelector selector = null;
String s = properties.getProperty("Message Selector");
if (s != null) {
selector = new MessageSelector(s);
try {
selector.compile();
} catch (InvalidSelectorException e) {
throw new JobException(e.toString(), e, false);
}
}
try {
receiver = ctx.queueManager.createQueueReceiver(queueName, null, selector);
pullTx = receiver.createTransaction(false);
targetQueue = new QueueImpl(properties.getProperty("Target Queue"));
sender = ctx.queueManager.createQueueSender(targetQueue.getQueueName(), null);
pushTx = sender.createTransaction();
} catch (Exception e) {
throw new JobException(e.toString(), e, false);
}
if (stopCalled) {
terminate();
return;
}
try {
MessageEntry entry = null;
while ((entry = pullTx.getMessage(0, selector)) != null) {
MessageImpl msg = entry.getMessage();
msg.setJMSDestination(targetQueue);
msg.setSourceRouter(null);
msg.setDestRouter(null);
pushTx.putMessage(msg);
cnt++;
pushTx.commit();
pullTx.commit();
if (stopCalled) {
terminate();
return;
}
pullTx = receiver.createTransaction(false);
pushTx = sender.createTransaction();
}
} catch (Exception e) {
terminate();
throw new JobException(e.toString(), e, false);
}
}
terminate();
jobTerminationListener.jobTerminated(cnt + " Messages moved");
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/start, properties=" + properties + " done, cnt=" + cnt);
}
use of com.swiftmq.jms.QueueImpl in project swiftmq-ce by iitsoftware.
the class BrowserManager method createBrowser.
public void createBrowser(CreateBrowserRequest request) {
CreateBrowserReply reply = (CreateBrowserReply) request.createReply();
QueueImpl queue = request.getQueue();
String messageSelector = request.getMessageSelector();
MessageSelector msel = null;
String queueName = null;
try {
queueName = queue.getQueueName();
} catch (JMSException ignored) {
}
try {
if (messageSelector != null) {
msel = new MessageSelector(messageSelector);
msel.compile();
}
if (!ctx.queueManager.isQueueRunning(queueName)) {
ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/" + toString() + ": Invalid destination: " + queueName);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + ": Invalid destination: " + queue);
reply.setOk(false);
reply.setException(new InvalidDestinationException("Invalid destination: " + queueName));
} else {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + ": Creating browser with selector: " + msel);
com.swiftmq.swiftlet.queue.QueueBrowser queueBrowser = ctx.queueManager.createQueueBrowser(queueName, ctx.activeLogin, msel);
int idx = ArrayListTool.setFirstFreeOrExpand(queueBrowsers, queueBrowser);
reply.setOk(true);
reply.setQueueBrowserId(idx);
if (browserEntityList != null) {
Entity browserEntity = browserEntityList.createEntity();
browserEntity.setName(queueName + "-" + idx);
browserEntity.setDynamicObject(queueBrowser);
browserEntity.createCommands();
Property prop = browserEntity.getProperty("queue");
prop.setValue(queueName);
prop.setReadOnly(true);
prop = browserEntity.getProperty("selector");
if (msel != null) {
prop.setValue(msel.getConditionString());
}
prop.setReadOnly(true);
browserEntityList.addEntity(browserEntity);
}
}
} catch (InvalidSelectorException e) {
ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/" + toString() + ": CreateBrowser has invalid Selector: " + e);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + ": CreateBrowser has invalid Selector: " + e);
reply.setOk(false);
reply.setException(e);
} catch (Exception e) {
ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/" + toString() + ": Exception during createQueueBrowser: " + e);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + ": Exception during createQueueBrowser: " + e);
reply.setOk(false);
reply.setException(e);
}
reply.send();
}
Aggregations