Search in sources :

Example 6 with MessageSelector

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();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) QueueImpl(com.swiftmq.jms.QueueImpl) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) MessageSelector(com.swiftmq.ms.MessageSelector) Property(com.swiftmq.mgmt.Property)

Example 7 with MessageSelector

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();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) QueueImpl(com.swiftmq.jms.QueueImpl) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) MessageSelector(com.swiftmq.ms.MessageSelector) Property(com.swiftmq.mgmt.Property)

Example 8 with MessageSelector

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();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) QueueImpl(com.swiftmq.jms.QueueImpl) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) MessageSelector(com.swiftmq.ms.MessageSelector) Property(com.swiftmq.mgmt.Property)

Example 9 with MessageSelector

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;
}
Also used : QueueReceiver(com.swiftmq.swiftlet.queue.QueueReceiver) MessageSelector(com.swiftmq.ms.MessageSelector) QueueMessageProcessor(com.swiftmq.impl.streams.processor.QueueMessageProcessor)

Example 10 with MessageSelector

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) {
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) MessageSelector(com.swiftmq.ms.MessageSelector) UnknownHostException(java.net.UnknownHostException) QueueException(com.swiftmq.swiftlet.queue.QueueException) InvalidSelectorException(javax.jms.InvalidSelectorException)

Aggregations

MessageSelector (com.swiftmq.ms.MessageSelector)31 InvalidSelectorException (javax.jms.InvalidSelectorException)11 QueueImpl (com.swiftmq.jms.QueueImpl)9 InvalidDestinationException (javax.jms.InvalidDestinationException)8 JMSException (javax.jms.JMSException)8 Entity (com.swiftmq.mgmt.Entity)7 Property (com.swiftmq.mgmt.Property)7 MessageImpl (com.swiftmq.jms.MessageImpl)5 TopicImpl (com.swiftmq.jms.TopicImpl)4 IllegalStateException (javax.jms.IllegalStateException)4 QueueReceiver (com.swiftmq.swiftlet.queue.QueueReceiver)3 JobException (com.swiftmq.swiftlet.scheduler.JobException)3 Iterator (java.util.Iterator)3 Map (java.util.Map)3 Message (com.swiftmq.impl.streams.comp.message.Message)2 QueueMessageProcessor (com.swiftmq.impl.streams.processor.QueueMessageProcessor)2 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)2 ActiveLogin (com.swiftmq.swiftlet.auth.ActiveLogin)2 AuthenticationException (com.swiftmq.swiftlet.auth.AuthenticationException)2 AbstractQueue (com.swiftmq.swiftlet.queue.AbstractQueue)2