Search in sources :

Example 26 with TopicImpl

use of com.swiftmq.jms.TopicImpl in project swiftmq-ce by iitsoftware.

the class NontransactedTopicSession method visitCreateDurableRequest.

public void visitCreateDurableRequest(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);
        consumer.createReadTransaction();
        consumer.createTransaction();
        reply.setOk(true);
        reply.setTopicSubscriberId(consumerId);
        reply.setQueueName(((TopicDurableConsumer) consumer).getQueueName() + '@' + SwiftletManager.getInstance().getRouterName());
        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);
        }
    } 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 instanceof JMSException) ? e1 : new javax.jms.JMSException(e1.toString()));
    }
    reply.send();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) JMSException(javax.jms.JMSException) 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 27 with TopicImpl

use of com.swiftmq.jms.TopicImpl in project swiftmq-ce by iitsoftware.

the class NontransactedTopicSession 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);
        }
    } 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) JMSException(javax.jms.JMSException) TopicImpl(com.swiftmq.jms.TopicImpl) 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)

Example 28 with TopicImpl

use of com.swiftmq.jms.TopicImpl in project swiftmq-ce by iitsoftware.

the class NontransactedTopicSession method visitCreateSubscriberRequest.

public void visitCreateSubscriberRequest(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);
            }
        }
        consumer.createReadTransaction();
        consumer.createTransaction();
        reply.setOk(true);
        reply.setTopicSubscriberId(consumerId);
        reply.setTmpQueueName(((TopicConsumer) consumer).getQueueName());
        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);
        }
    } 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(new javax.jms.JMSException(e1.toString()));
    }
    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 29 with TopicImpl

use of com.swiftmq.jms.TopicImpl in project swiftmq-ce by iitsoftware.

the class NontransactedTopicSession method visitCreateSubscriberRequest.

public void visitCreateSubscriberRequest(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);
            }
        }
        consumer.createReadTransaction();
        consumer.createTransaction();
        reply.setOk(true);
        reply.setTopicSubscriberId(consumerId);
        reply.setTmpQueueName(((TopicConsumer) consumer).getQueueName());
        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);
        }
    } 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(new javax.jms.JMSException(e1.toString()));
    }
    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 30 with TopicImpl

use of com.swiftmq.jms.TopicImpl in project swiftmq-ce by iitsoftware.

the class NontransactedTopicSession 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);
        }
    } 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) JMSException(javax.jms.JMSException) TopicImpl(com.swiftmq.jms.TopicImpl) 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)

Aggregations

TopicImpl (com.swiftmq.jms.TopicImpl)71 JMSException (javax.jms.JMSException)62 InvalidSelectorException (javax.jms.InvalidSelectorException)58 ResourceLimitException (com.swiftmq.swiftlet.auth.ResourceLimitException)56 Entity (com.swiftmq.mgmt.Entity)42 Property (com.swiftmq.mgmt.Property)42 MessageImpl (com.swiftmq.jms.MessageImpl)17 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)14 DataByteArrayInputStream (com.swiftmq.tools.util.DataByteArrayInputStream)8 RingBuffer (com.swiftmq.tools.collection.RingBuffer)7 EntityList (com.swiftmq.mgmt.EntityList)6 List (java.util.List)6 QueueImpl (com.swiftmq.jms.QueueImpl)4 MessageSelector (com.swiftmq.ms.MessageSelector)4 AuthenticationException (com.swiftmq.swiftlet.auth.AuthenticationException)4 TopicException (com.swiftmq.swiftlet.topic.TopicException)4 IOException (java.io.IOException)4 SwiftletException (com.swiftmq.swiftlet.SwiftletException)3 InvalidDestinationException (javax.jms.InvalidDestinationException)3 ActiveLogin (com.swiftmq.swiftlet.auth.ActiveLogin)2