Search in sources :

Example 36 with Entity

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

the class RoutingConnectorJob method doAction.

private void doAction(boolean b) throws JobException {
    Entity entity = ctx.root.getEntity("connectors").getEntity(name);
    if (entity == null)
        throw new JobException("Routing Connector '" + name + "' is undefined!", null, false);
    Property prop = entity.getProperty("enabled");
    boolean enabled = ((Boolean) prop.getValue()).booleanValue();
    try {
        if (enabled != b)
            prop.setValue(new Boolean(b));
    } catch (Exception e) {
        throw new JobException(e.getMessage(), e, false);
    }
}
Also used : JobException(com.swiftmq.swiftlet.scheduler.JobException) Entity(com.swiftmq.mgmt.Entity) Property(com.swiftmq.mgmt.Property) JobException(com.swiftmq.swiftlet.scheduler.JobException)

Example 37 with Entity

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

the class RouteTable method addUsageEntity.

private void addUsageEntity(Route route) {
    try {
        Entity destEntity = dynRoutes.getEntity(route.getDestinationRouter());
        if (destEntity == null) {
            destEntity = dynRoutes.createEntity();
            destEntity.setName(route.getDestinationRouter());
            destEntity.createCommands();
            dynRoutes.addEntity(destEntity);
        }
        EntityList routes = (EntityList) destEntity.getEntity("dynamic-routes");
        Entity dr = routes.createEntity();
        dr.setName(route.getKey());
        dr.createCommands();
        routes.addEntity(dr);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Example 38 with Entity

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

the class TransactedTopicSession method visit.

public void visit(CreateDurableRequest req) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitCreateDurableRequest");
    CreateDurableReply reply = (CreateDurableReply) req.createReply();
    try {
        ctx.activeLogin.getResourceLimitGroup().incConsumers();
    } catch (ResourceLimitException e) {
        reply.setOk(false);
        reply.setException(new JMSException(e.toString()));
        reply.send();
        return;
    }
    TopicImpl topic = req.getTopic();
    String messageSelector = req.getMessageSelector();
    boolean noLocal = req.isNoLocal();
    String durableName = req.getDurableName();
    try {
        int consumerId = 0;
        TopicDurableConsumer consumer = null;
        consumerId = ArrayListTool.setFirstFreeOrExpand(consumerList, null);
        consumer = new TopicDurableConsumer(ctx, durableName, topic, messageSelector, noLocal);
        consumerList.set(consumerId, consumer);
        reply.setOk(true);
        reply.setTopicSubscriberId(consumerId);
        if (durableEntityList != null) {
            Entity durEntity = durableEntityList.createEntity();
            durEntity.setName(ctx.activeLogin.getClientId() + "$" + durableName);
            durEntity.createCommands();
            Property prop = durEntity.getProperty("clientid");
            prop.setValue(ctx.activeLogin.getClientId());
            prop.setReadOnly(true);
            prop = durEntity.getProperty("durablename");
            prop.setValue(durableName);
            prop.setReadOnly(true);
            prop = durEntity.getProperty("topic");
            prop.setValue(topic.getTopicName());
            prop.setReadOnly(true);
            prop = durEntity.getProperty("boundto");
            prop.setValue(consumer.getQueueName());
            prop.setReadOnly(true);
            prop = durEntity.getProperty("nolocal");
            prop.setValue(new Boolean(noLocal));
            prop.setReadOnly(true);
            prop = durEntity.getProperty("selector");
            if (messageSelector != null) {
                prop.setValue(messageSelector);
            }
            prop.setReadOnly(true);
            durableEntityList.addEntity(durEntity);
        }
        consumer.createReadTransaction();
        // enlist it at the transaction manager
        transactionManager.addTransactionFactory(consumer);
    } catch (InvalidSelectorException e) {
        ctx.activeLogin.getResourceLimitGroup().decConsumers();
        ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/CreateDurable has invalid Selector: " + e);
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/CreateDurable has invalid Selector: " + e);
        reply.setOk(false);
        reply.setException(e);
    } catch (Exception e1) {
        ctx.activeLogin.getResourceLimitGroup().decConsumers();
        ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/Exception during create durable: " + e1);
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/Exception during create durable: " + e1);
        reply.setOk(false);
        reply.setException(e1);
    }
    reply.send();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) JMSException(javax.jms.JMSException) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) TopicImpl(com.swiftmq.jms.TopicImpl) Property(com.swiftmq.mgmt.Property) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException)

Example 39 with Entity

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

the class TransactedUnifiedSession method visit.

public void visit(CreateDurableRequest req) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitCreateDurableRequest");
    CreateDurableReply reply = (CreateDurableReply) req.createReply();
    try {
        ctx.activeLogin.getResourceLimitGroup().incConsumers();
    } catch (ResourceLimitException e) {
        reply.setOk(false);
        reply.setException(new JMSException(e.toString()));
        reply.send();
        return;
    }
    TopicImpl topic = req.getTopic();
    String messageSelector = req.getMessageSelector();
    boolean noLocal = req.isNoLocal();
    String durableName = req.getDurableName();
    try {
        int consumerId = 0;
        TopicDurableConsumer consumer = null;
        consumerId = ArrayListTool.setFirstFreeOrExpand(consumerList, null);
        consumer = new TopicDurableConsumer(ctx, durableName, topic, messageSelector, noLocal);
        consumerList.set(consumerId, consumer);
        reply.setOk(true);
        reply.setTopicSubscriberId(consumerId);
        if (durableEntityList != null) {
            Entity durEntity = durableEntityList.createEntity();
            durEntity.setName(ctx.activeLogin.getClientId() + "$" + durableName);
            durEntity.createCommands();
            Property prop = durEntity.getProperty("clientid");
            prop.setValue(ctx.activeLogin.getClientId());
            prop.setReadOnly(true);
            prop = durEntity.getProperty("durablename");
            prop.setValue(durableName);
            prop.setReadOnly(true);
            prop = durEntity.getProperty("topic");
            prop.setValue(topic.getTopicName());
            prop.setReadOnly(true);
            prop = durEntity.getProperty("boundto");
            prop.setValue(consumer.getQueueName());
            prop.setReadOnly(true);
            prop = durEntity.getProperty("nolocal");
            prop.setValue(new Boolean(noLocal));
            prop.setReadOnly(true);
            prop = durEntity.getProperty("selector");
            if (messageSelector != null) {
                prop.setValue(messageSelector);
            }
            prop.setReadOnly(true);
            durableEntityList.addEntity(durEntity);
        }
        consumer.createReadTransaction();
        // enlist it at the transaction manager
        transactionManager.addTransactionFactory(consumer);
    } catch (InvalidSelectorException e) {
        ctx.activeLogin.getResourceLimitGroup().decConsumers();
        ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/CreateDurable has invalid Selector: " + e);
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/CreateDurable has invalid Selector: " + e);
        reply.setOk(false);
        reply.setException(e);
    } catch (Exception e1) {
        ctx.activeLogin.getResourceLimitGroup().decConsumers();
        ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/Exception during create durable: " + e1);
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/Exception during create durable: " + e1);
        reply.setOk(false);
        reply.setException(e1);
    }
    reply.send();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) JMSException(javax.jms.JMSException) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) Property(com.swiftmq.mgmt.Property) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException)

Example 40 with Entity

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

the class TransactedUnifiedSession method visit.

public void visit(CreateSubscriberRequest req) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitCreateSubscriberRequest");
    CreateSubscriberReply reply = (CreateSubscriberReply) req.createReply();
    try {
        ctx.activeLogin.getResourceLimitGroup().incConsumers();
    } catch (ResourceLimitException e) {
        reply.setOk(false);
        reply.setException(new JMSException(e.toString()));
        reply.send();
        return;
    }
    TopicImpl topic = req.getTopic();
    String messageSelector = req.getMessageSelector();
    boolean noLocal = req.isNoLocal();
    try {
        Entity subEntity = null;
        if (subscriberEntityList != null)
            subEntity = subscriberEntityList.createEntity();
        int consumerId = 0;
        TopicConsumer consumer = null;
        if (topic.getType() == DestinationFactory.TYPE_TOPIC) {
            consumerId = ArrayListTool.setFirstFreeOrExpand(consumerList, null);
            consumer = new TopicConsumer(ctx, topic, messageSelector, noLocal);
            consumerList.set(consumerId, consumer);
            if (subEntity != null) {
                Property prop = subEntity.getProperty("topic");
                prop.setReadOnly(false);
                prop.setValue(topic.getTopicName());
                prop.setReadOnly(true);
                prop = subEntity.getProperty("boundto");
                prop.setReadOnly(false);
                prop.setValue(topic.getQueueName());
                prop.setReadOnly(true);
                subEntity.setDynamicObject(consumer);
            }
            if (subEntity != null)
                subEntity.setName(topic.getTopicName() + "-" + consumerId);
        } else {
            consumerId = ArrayListTool.setFirstFreeOrExpand(consumerList, null);
            consumer = new TopicConsumer(ctx, topic, messageSelector, noLocal);
            consumerList.set(consumerId, consumer);
            if (subEntity != null)
                subEntity.setDynamicObject(consumer);
            if (subEntity != null) {
                subEntity.setName(topic.getQueueName() + "-" + consumerId);
                Property prop = subEntity.getProperty("temptopic");
                prop.setReadOnly(false);
                prop.setValue(new Boolean(true));
                prop.setReadOnly(true);
                prop = subEntity.getProperty("boundto");
                prop.setReadOnly(false);
                prop.setValue(topic.getQueueName());
                prop.setReadOnly(true);
            }
        }
        reply.setOk(true);
        reply.setTopicSubscriberId(consumerId);
        if (subEntity != null) {
            Property prop = subEntity.getProperty("nolocal");
            prop.setReadOnly(false);
            prop.setValue(new Boolean(noLocal));
            prop.setReadOnly(true);
            subEntity.createCommands();
            prop = subEntity.getProperty("selector");
            if (messageSelector != null) {
                prop.setValue(messageSelector);
            }
            prop.setReadOnly(true);
            subscriberEntityList.addEntity(subEntity);
        }
        consumer.createReadTransaction();
        // enlist it at the transaction manager
        transactionManager.addTransactionFactory(consumer);
    } catch (InvalidSelectorException e) {
        ctx.activeLogin.getResourceLimitGroup().decConsumers();
        ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/CreateSubscriber has invalid Selector: " + e);
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/CreateSubscriber has invalid Selector: " + e);
        reply.setOk(false);
        reply.setException(e);
    } catch (Exception e1) {
        ctx.activeLogin.getResourceLimitGroup().decConsumers();
        ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/Exception during create subscriber: " + e1);
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/Exception during create subscriber: " + e1);
        reply.setOk(false);
        reply.setException(e1);
    }
    reply.send();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) JMSException(javax.jms.JMSException) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) Property(com.swiftmq.mgmt.Property) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException)

Aggregations

Entity (com.swiftmq.mgmt.Entity)179 Property (com.swiftmq.mgmt.Property)154 JMSException (javax.jms.JMSException)149 InvalidSelectorException (javax.jms.InvalidSelectorException)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 EntityList (com.swiftmq.mgmt.EntityList)15 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)11 Map (java.util.Map)10 Iterator (java.util.Iterator)9 MessageSelector (com.swiftmq.ms.MessageSelector)7 EntityAddException (com.swiftmq.mgmt.EntityAddException)5 QueueException (com.swiftmq.swiftlet.queue.QueueException)2 QueueTransactionClosedException (com.swiftmq.swiftlet.queue.QueueTransactionClosedException)2 JobException (com.swiftmq.swiftlet.scheduler.JobException)2 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)2 HashMap (java.util.HashMap)2