use of com.swiftmq.ms.MessageSelector 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();
}
use of com.swiftmq.ms.MessageSelector 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(new javax.jms.JMSException(e.toString()));
}
reply.send();
}
use of com.swiftmq.ms.MessageSelector 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(new javax.jms.JMSException(e.toString()));
}
reply.send();
}
use of com.swiftmq.ms.MessageSelector in project swiftmq-ce by iitsoftware.
the class QueueInput method start.
@Override
public void start() throws Exception {
if (started)
return;
MessageSelector ms = null;
if (selector != null) {
ms = new MessageSelector(selector);
ms.compile();
}
QueueReceiver receiver = ctx.ctx.queueManager.createQueueReceiver(destinationName, (ActiveLogin) null, ms);
messageProcessor = new QueueMessageProcessor(ctx, this, receiver, ms);
messageProcessor.restart();
started = true;
}
use of com.swiftmq.ms.MessageSelector in project swiftmq-ce by iitsoftware.
the class CompositeQueue method init.
private void init() {
try {
StringBuffer b = new StringBuffer(InetAddress.getLocalHost().getHostName());
b.append('/');
b.append(IdGenerator.getInstance().nextId('/'));
b.append('/');
idPrefix = b.toString();
} catch (UnknownHostException e) {
}
queueBindings = (EntityList) compositeQueueEntity.getEntity("queue-bindings");
queueBindingsAdapter = new EntityListEventAdapter((EntityList) compositeQueueEntity.getEntity("queue-bindings"), true, false) {
public void onEntityAdd(Entity parent, Entity newEntity) throws EntityAddException {
try {
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "onEntityAdd (Queue Binding): " + newEntity.getName() + " ...");
Property prop = newEntity.getProperty("message-selector");
String selector = (String) prop.getValue();
if (selector != null && selector.trim().length() > 0) {
MessageSelector ms = new MessageSelector(selector);
ms.compile();
newEntity.setUserObject(ms);
}
prop.setPropertyChangeListener(new MSChangeListener(newEntity));
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "onEntityAdd (Queue Binding): " + newEntity.getName() + " done.");
} catch (Exception e) {
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "onEntityAdd (Queue Binding), exception=" + e);
throw new EntityAddException(e.getMessage());
}
}
};
try {
queueBindingsAdapter.init();
} catch (Exception e) {
}
topicBindings = (EntityList) compositeQueueEntity.getEntity("topic-bindings");
topicBindingsAdapter = new EntityListEventAdapter((EntityList) compositeQueueEntity.getEntity("topic-bindings"), true, false) {
public void onEntityAdd(Entity parent, Entity newEntity) throws EntityAddException {
try {
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "onEntityAdd (Topic Binding): " + newEntity.getName() + " ...");
Property prop = newEntity.getProperty("message-selector");
String selector = (String) prop.getValue();
if (selector != null && selector.trim().length() > 0) {
MessageSelector ms = new MessageSelector(selector);
ms.compile();
newEntity.setUserObject(ms);
}
prop.setPropertyChangeListener(new MSChangeListener(newEntity));
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "onEntityAdd (Topic Binding): " + newEntity.getName() + " done.");
} catch (Exception e) {
if (ctx.queueSpace.enabled)
ctx.queueSpace.trace(getQueueName(), "onEntityAdd (Topic Binding), exception=" + e);
throw new EntityAddException(e.getMessage());
}
}
};
try {
topicBindingsAdapter.init();
} catch (Exception e) {
}
}
Aggregations