Search in sources :

Example 71 with Property

use of com.swiftmq.mgmt.Property 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 72 with Property

use of com.swiftmq.mgmt.Property in project swiftmq-ce by iitsoftware.

the class TransactedUnifiedSession method visitCreatePublisherRequest.

public void visitCreatePublisherRequest(CreatePublisherRequest req) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitCreatePublisherRequest");
    CreatePublisherReply reply = (CreatePublisherReply) req.createReply();
    try {
        ctx.activeLogin.getResourceLimitGroup().incProducers();
    } catch (ResourceLimitException e) {
        reply.setOk(false);
        reply.setException(new JMSException(e.toString()));
        reply.send();
        return;
    }
    TopicImpl topic = req.getTopic();
    try {
        if (topic.getType() != DestinationFactory.TYPE_TEMPTOPIC)
            ctx.authSwiftlet.verifyTopicSenderSubscription(topic.getTopicName(), ctx.activeLogin.getLoginId());
        int producerId;
        TopicProducer producer;
        producerId = ArrayListTool.setFirstFreeOrExpand(producerList, null);
        producer = new TopicProducer(ctx, topic);
        producerList.set(producerId, producer);
        reply.setTopicPublisherId(producerId);
        reply.setOk(true);
        if (publisherEntityList != null) {
            Entity publisherEntity = publisherEntityList.createEntity();
            publisherEntity.setName(topic.getTopicName() + "-" + producerId);
            publisherEntity.setDynamicObject(producer);
            publisherEntity.createCommands();
            Property prop = publisherEntity.getProperty("topic");
            prop.setReadOnly(false);
            prop.setValue(topic.getTopicName());
            prop.setReadOnly(true);
            publisherEntityList.addEntity(publisherEntity);
        }
        // enlist it at the transaction manager
        transactionManager.addTransactionFactory(producer);
    } catch (Exception e) {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/exception creating publisher: " + e.getMessage());
        ctx.logSwiftlet.logError("sys$jms", ctx.tracePrefix + "/exception creating publisher: " + e.getMessage());
        reply.setOk(false);
        reply.setException((e instanceof JMSException) ? e : new javax.jms.JMSException(e.toString()));
        ctx.activeLogin.getResourceLimitGroup().decProducers();
    }
    reply.send();
}
Also used : Entity(com.swiftmq.mgmt.Entity) com.swiftmq.jms(com.swiftmq.jms) JMSException(javax.jms.JMSException) Property(com.swiftmq.mgmt.Property) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException)

Example 73 with Property

use of com.swiftmq.mgmt.Property 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 74 with Property

use of com.swiftmq.mgmt.Property 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 75 with Property

use of com.swiftmq.mgmt.Property in project swiftmq-ce by iitsoftware.

the class Output method collect.

/**
 * Internal use.
 */
public void collect(long interval) {
    if (usage == null)
        return;
    try {
        Property msgSent = usage.getProperty("messages-sent");
        msgSent.setValue(sent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Property(com.swiftmq.mgmt.Property) QueueException(com.swiftmq.swiftlet.queue.QueueException)

Aggregations

Property (com.swiftmq.mgmt.Property)166 Entity (com.swiftmq.mgmt.Entity)154 InvalidSelectorException (javax.jms.InvalidSelectorException)147 JMSException (javax.jms.JMSException)147 ResourceLimitException (com.swiftmq.swiftlet.auth.ResourceLimitException)140 InvalidDestinationException (javax.jms.InvalidDestinationException)105 TopicImpl (com.swiftmq.jms.TopicImpl)42 QueueImpl (com.swiftmq.jms.QueueImpl)35 com.swiftmq.jms (com.swiftmq.jms)16 MessageSelector (com.swiftmq.ms.MessageSelector)7 PropertyChangeException (com.swiftmq.mgmt.PropertyChangeException)4 QueueException (com.swiftmq.swiftlet.queue.QueueException)4 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)3 PropertyChangeAdapter (com.swiftmq.mgmt.PropertyChangeAdapter)3 NonPersistentStore (com.swiftmq.swiftlet.store.NonPersistentStore)3 PropertyChangeListener (com.swiftmq.mgmt.PropertyChangeListener)2 PropertyWatchListener (com.swiftmq.mgmt.PropertyWatchListener)2 SwiftletManagerAdapter (com.swiftmq.swiftlet.event.SwiftletManagerAdapter)2 SwiftletManagerEvent (com.swiftmq.swiftlet.event.SwiftletManagerEvent)2 MgmtSwiftlet (com.swiftmq.swiftlet.mgmt.MgmtSwiftlet)2