Search in sources :

Example 96 with Property

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

the class NontransactedQueueSession 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);
        consumer.createReadTransaction();
        consumer.createTransaction();
        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);
        }
    } 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) QueueImpl(com.swiftmq.jms.QueueImpl) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException)

Example 97 with Property

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

the class TransactedQueueSession 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) QueueImpl(com.swiftmq.jms.QueueImpl) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException)

Example 98 with Property

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

the class StableStore method init.

private void init() throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/init ...");
    nFree = 0;
    if (freePoolEnabled)
        freePool = new IntRingBuffer[10];
    filename = path + File.separatorChar + FILENAME;
    emptyData = new byte[Page.PAGE_SIZE];
    // emtpy
    emptyData[0] = 1;
    for (int i = 1; i < Page.PAGE_SIZE; i++) emptyData[i] = 0;
    file = new RandomAccessFile(filename, "rw");
    fileLength = file.length();
    if (fileLength > 0) {
        numberPages = (int) (fileLength / Page.PAGE_SIZE);
        if (!offline)
            shrinkFile();
    } else
        initialize(initialPages);
    sync();
    if (freePoolEnabled)
        buildFreePageList();
    if (!offline) {
        Entity entity = ctx.filesList.createEntity();
        entity.setName(FILENAME);
        entity.createCommands();
        ctx.filesList.addEntity(entity);
        freeProp = entity.getProperty("free-pages");
        usedProp = entity.getProperty("used-pages");
        fileSizeProp = entity.getProperty("file-size");
        sizeCollectProp = ctx.dbEntity.getProperty("size-collect-interval");
        collectInterval = (long) (Long) sizeCollectProp.getValue();
        startTimer();
        PropertyChangeListener propChangeListener = new PropertyChangeListener() {

            public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
                stopTimer();
                collectInterval = (Long) newValue;
                startTimer();
            }
        };
        sizeCollectProp.setPropertyChangeListener(propChangeListener);
        swiftletManagerAdapter = new SwiftletManagerAdapter() {

            public void swiftletStarted(SwiftletManagerEvent event) {
                mgmtSwiftlet = (MgmtSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$mgmt");
                mgmtSwiftlet.addMgmtListener(StableStore.this);
            }
        };
        SwiftletManager.getInstance().addSwiftletManagerListener("sys$mgmt", swiftletManagerAdapter);
    }
    ctx.logSwiftlet.logInformation("sys$store", toString() + "/init done, size=" + numberPages + ", freePages=" + getNumberFreePages());
}
Also used : IntRingBuffer(com.swiftmq.tools.collection.IntRingBuffer) Entity(com.swiftmq.mgmt.Entity) SwiftletManagerEvent(com.swiftmq.swiftlet.event.SwiftletManagerEvent) RandomAccessFile(java.io.RandomAccessFile) PropertyChangeListener(com.swiftmq.mgmt.PropertyChangeListener) MgmtSwiftlet(com.swiftmq.swiftlet.mgmt.MgmtSwiftlet) Property(com.swiftmq.mgmt.Property) SwiftletManagerAdapter(com.swiftmq.swiftlet.event.SwiftletManagerAdapter)

Example 99 with Property

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

the class JobGroupImpl method addJobFactory.

public synchronized void addJobFactory(String jobName, JobFactory jobFactory) {
    if (!hasJobFactory(jobName)) {
        Entity entity = jobList.createEntity();
        entity.setName(jobFactory.getName());
        entity.createCommands();
        entity.setDynamic(true);
        entity.setDynamicObject(jobFactory);
        try {
            Property prop = entity.getProperty("description");
            prop.setReadOnly(false);
            prop.setValue(jobFactory.getDescription());
            prop.setReadOnly(true);
            Map parmMap = jobFactory.getJobParameters();
            if (parmMap != null) {
                EntityList parmList = (EntityList) entity.getEntity("parameters");
                for (Iterator iter = parmMap.entrySet().iterator(); iter.hasNext(); ) {
                    JobParameter parm = (JobParameter) ((Map.Entry) iter.next()).getValue();
                    Entity pe = parmList.createEntity();
                    pe.setName(parm.getName());
                    pe.setDynamic(true);
                    pe.createCommands();
                    pe.setDynamicObject(parm);
                    prop = pe.getProperty("description");
                    prop.setReadOnly(false);
                    prop.setValue(parm.getDescription());
                    prop.setReadOnly(true);
                    prop = pe.getProperty("default");
                    prop.setReadOnly(false);
                    prop.setValue(parm.getDefaultValue());
                    prop.setReadOnly(true);
                    prop = pe.getProperty("mandatory");
                    prop.setReadOnly(false);
                    prop.setValue(new Boolean(parm.isMandatory()));
                    prop.setReadOnly(true);
                    parmList.addEntity(pe);
                }
            }
            jobList.addEntity(entity);
            ctx.scheduler.enqueue(new JobFactoryAdded(name, jobName, jobFactory));
        } catch (Exception e) {
        }
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) Iterator(java.util.Iterator) JobFactoryAdded(com.swiftmq.impl.scheduler.standard.po.JobFactoryAdded) Property(com.swiftmq.mgmt.Property) Map(java.util.Map) JobParameter(com.swiftmq.swiftlet.scheduler.JobParameter) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Example 100 with Property

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

the class NontransactedQueueSession 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 {
        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);
        }
    } 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) 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)

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