Search in sources :

Example 41 with Property

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

the class TransactedUnifiedSession method visit.

public void visit(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);
        ctx.activeLogin.getResourceLimitGroup().decProducers();
    }
    reply.send();
}
Also used : Entity(com.swiftmq.mgmt.Entity) JMSException(javax.jms.JMSException) Property(com.swiftmq.mgmt.Property) 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 42 with Property

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

the class TransactedUnifiedSession method visit.

public void visit(CreateConsumerRequest req) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitCreateConsumerRequest");
    CreateConsumerReply reply = (CreateConsumerReply) req.createReply();
    try {
        ctx.activeLogin.getResourceLimitGroup().incConsumers();
    } catch (ResourceLimitException e) {
        reply.setOk(false);
        reply.setException(new JMSException(e.toString()));
        reply.send();
        return;
    }
    QueueImpl queue = req.getQueue();
    String messageSelector = req.getMessageSelector();
    String queueName = null;
    try {
        queueName = queue.getQueueName();
    } catch (JMSException ignored) {
    }
    try {
        queueName = validateDestination(queueName);
        int consumerId = 0;
        QueueConsumer consumer = null;
        consumerId = ArrayListTool.setFirstFreeOrExpand(consumerList, null);
        consumer = new QueueConsumer(ctx, queueName, messageSelector);
        consumerList.set(consumerId, consumer);
        reply.setOk(true);
        reply.setQueueConsumerId(consumerId);
        if (receiverEntityList != null) {
            Entity consEntity = receiverEntityList.createEntity();
            consEntity.setName(queueName + "-" + consumerId);
            consEntity.setDynamicObject(consumer);
            consEntity.createCommands();
            Property prop = consEntity.getProperty("queue");
            prop.setValue(queueName);
            prop.setReadOnly(true);
            prop = consEntity.getProperty("selector");
            if (messageSelector != null) {
                prop.setValue(messageSelector);
            }
            prop.setReadOnly(true);
            receiverEntityList.addEntity(consEntity);
        }
        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 + "/CreateConsumer has invalid Selector: " + e);
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/CreateConsumer 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 consumer: " + e1);
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/Exception during create consumer: " + e1);
        reply.setOk(false);
        reply.setException(e1);
    }
    reply.send();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) JMSException(javax.jms.JMSException) Property(com.swiftmq.mgmt.Property) 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 43 with Property

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

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

the class TransactedQueueSession method visit.

public void visit(CreateProducerRequest req) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitCreateProducerRequest");
    CreateProducerReply reply = (CreateProducerReply) req.createReply();
    try {
        ctx.activeLogin.getResourceLimitGroup().incProducers();
    } catch (ResourceLimitException e) {
        reply.setOk(false);
        reply.setException(new JMSException(e.toString()));
        reply.send();
        return;
    }
    QueueImpl queue = req.getQueue();
    try {
        if (!ctx.queueManager.isQueueRunning(queue.getQueueName()))
            throw new InvalidDestinationException("Invalid destination: " + queue.getQueueName());
        int producerId;
        QueueProducer producer;
        producerId = ArrayListTool.setFirstFreeOrExpand(producerList, null);
        producer = new QueueProducer(ctx, queue.getQueueName());
        producerList.set(producerId, producer);
        reply.setQueueProducerId(producerId);
        reply.setOk(true);
        if (senderEntityList != null) {
            Entity senderEntity = senderEntityList.createEntity();
            senderEntity.setName(queue.getQueueName() + "-" + producerId);
            senderEntity.setDynamicObject(producer);
            senderEntity.createCommands();
            Property prop = senderEntity.getProperty("queue");
            prop.setValue(queue.getQueueName());
            prop.setReadOnly(true);
            senderEntityList.addEntity(senderEntity);
        }
        // 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 producer: " + e.getMessage());
        ctx.logSwiftlet.logError("sys$jms", ctx.tracePrefix + "/exception creating producer: " + e.getMessage());
        reply.setOk(false);
        reply.setException(e);
        ctx.activeLogin.getResourceLimitGroup().decProducers();
    }
    reply.send();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) Property(com.swiftmq.mgmt.Property) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) QueueImpl(com.swiftmq.jms.QueueImpl) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException)

Example 45 with Property

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

the class NontransactedTopicSession method visit.

public void visit(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);
        }
    } 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);
        ctx.activeLogin.getResourceLimitGroup().decProducers();
    }
    reply.send();
}
Also used : Entity(com.swiftmq.mgmt.Entity) JMSException(javax.jms.JMSException) TopicImpl(com.swiftmq.jms.TopicImpl) Property(com.swiftmq.mgmt.Property) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException)

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