Search in sources :

Example 76 with Property

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

the class RegularQueueFactory method createQueue.

public AbstractQueue createQueue(String queueName, Entity queueEntity) throws QueueException {
    PersistentStore pStore = null;
    NonPersistentStore nStore = null;
    try {
        pStore = ctx.storeSwiftlet.getPersistentStore(queueName);
        nStore = ctx.storeSwiftlet.getNonPersistentStore(queueName);
    } catch (Exception e) {
        e.printStackTrace();
        throw new QueueException(e.toString());
    }
    Property prop = queueEntity.getProperty(QueueManagerImpl.PROP_CACHE_SIZE);
    int cacheSize = ((Integer) prop.getValue()).intValue();
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_CACHE_SIZE_BYTES_KB);
    int cacheSizeBytesKB = ((Integer) prop.getValue()).intValue();
    Cache cache = new CacheImpl(cacheSize, cacheSizeBytesKB, pStore, nStore);
    cache.setCacheTable(ctx.cacheTableFactory.createCacheTable(queueName, cacheSize));
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_CACHE_SIZE);
    prop.setPropertyChangeListener(new PropertyChangeAdapter(cache) {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            Cache myCache = (Cache) configObject;
            myCache.setMaxMessages(((Integer) newValue).intValue());
        }
    });
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_CACHE_SIZE_BYTES_KB);
    prop.setPropertyChangeListener(new PropertyChangeAdapter(cache) {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            Cache myCache = (Cache) configObject;
            myCache.setMaxBytesKB(((Integer) newValue).intValue());
        }
    });
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_CLEANUP_INTERVAL);
    long cleanUp = ((Long) prop.getValue()).longValue();
    MessageQueue mq = ctx.messageQueueFactory.createMessageQueue(ctx, queueName, cache, pStore, nStore, cleanUp, myTP);
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_MESSAGES_MAXIMUM);
    int maxMessages = ((Integer) prop.getValue()).intValue();
    mq.setMaxMessages(maxMessages);
    prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            MessageQueue myMq = (MessageQueue) configObject;
            myMq.setMaxMessages(((Integer) newValue).intValue());
        }
    });
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_PERSISTENCE);
    int pm = SwiftUtilities.persistenceModeToInt((String) prop.getValue());
    mq.setPersistenceMode(pm);
    prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            MessageQueue myMq = (MessageQueue) configObject;
            myMq.setPersistenceMode(SwiftUtilities.persistenceModeToInt((String) newValue));
        }
    });
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_FLOWCONTROL_QUEUE_SIZE);
    int fcQueueSize = ((Integer) prop.getValue()).intValue();
    if (fcQueueSize >= 0)
        mq.setFlowController(new FlowControllerImpl(fcQueueSize, ctx.queueManager.getMaxFlowControlDelay()));
    prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            MessageQueue myMq = (MessageQueue) configObject;
            int newFcQueueSize = ((Integer) newValue).intValue();
            if (newFcQueueSize >= 0)
                myMq.setFlowController(new FlowControllerImpl(newFcQueueSize, ctx.queueManager.getMaxFlowControlDelay()));
            else
                myMq.setFlowController(null);
        }
    });
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_ENABLED);
    mq.setDuplicateDetectionEnabled(((Boolean) prop.getValue()).booleanValue());
    prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            MessageQueue myMq = (MessageQueue) configObject;
            myMq.setDuplicateDetectionEnabled(((Boolean) newValue).booleanValue());
        }
    });
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_BACKLOG_SIZE);
    mq.setDuplicateDetectionBacklogSize(((Integer) prop.getValue()).intValue());
    prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            MessageQueue myMq = (MessageQueue) configObject;
            myMq.setDuplicateDetectionBacklogSize(((Integer) newValue).intValue());
        }
    });
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_CONSUMER);
    if (prop != null) {
        mq.setConsumerMode(ctx.consumerModeInt((String) prop.getValue()));
        prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {

            public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
                MessageQueue myMq = (MessageQueue) configObject;
                int cm = ctx.consumerModeInt((String) newValue);
                if (cm == AbstractQueue.EXCLUSIVE && myMq.getReceiverCount() > 1)
                    throw new PropertyChangeException("Can't set EXCLUSIVE consumer mode - queue has already '" + myMq.getReceiverCount() + "' receivers");
                myMq.setConsumerMode(cm);
            }
        });
    }
    prop = queueEntity.getProperty(QueueManagerImpl.PROP_MONITOR_ALERT_THRESHOLD);
    if (prop != null) {
        mq.setMonitorAlertThreshold(((Integer) prop.getValue()).intValue());
        prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {

            public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
                MessageQueue myMq = (MessageQueue) configObject;
                myMq.setMonitorAlertThreshold(((Integer) newValue).intValue());
            }
        });
    }
    return mq;
}
Also used : NonPersistentStore(com.swiftmq.swiftlet.store.NonPersistentStore) PersistentStore(com.swiftmq.swiftlet.store.PersistentStore) PropertyChangeException(com.swiftmq.mgmt.PropertyChangeException) QueueException(com.swiftmq.swiftlet.queue.QueueException) PropertyChangeException(com.swiftmq.mgmt.PropertyChangeException) NonPersistentStore(com.swiftmq.swiftlet.store.NonPersistentStore) PropertyChangeAdapter(com.swiftmq.mgmt.PropertyChangeAdapter) QueueException(com.swiftmq.swiftlet.queue.QueueException) Property(com.swiftmq.mgmt.Property)

Example 77 with Property

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

the class SystemQueueFactory method createQueue.

public AbstractQueue createQueue(String queueName, Entity queueController) throws QueueException {
    PersistentStore pStore = null;
    NonPersistentStore nStore = null;
    try {
        pStore = ctx.storeSwiftlet.getPersistentStore(queueName);
        nStore = ctx.storeSwiftlet.getNonPersistentStore(queueName);
    } catch (Exception e) {
        throw new QueueException(e.toString());
    }
    Property prop = queueController.getProperty(QueueManagerImpl.PROP_CACHE_SIZE);
    int cacheSize = ((Integer) prop.getValue()).intValue();
    prop = queueController.getProperty(QueueManagerImpl.PROP_CACHE_SIZE_BYTES_KB);
    int cacheSizeBytesKB = ((Integer) prop.getValue()).intValue();
    Cache cache = new CacheImpl(cacheSize, cacheSizeBytesKB, pStore, nStore);
    cache.setCacheTable(ctx.cacheTableFactory.createCacheTable(queueName, cacheSize));
    prop = queueController.getProperty(QueueManagerImpl.PROP_CLEANUP_INTERVAL);
    long cleanUp = ((Long) prop.getValue()).longValue();
    MessageQueue mq = ctx.messageQueueFactory.createMessageQueue(ctx, queueName, cache, pStore, nStore, cleanUp, myTP);
    prop = queueController.getProperty(QueueManagerImpl.PROP_MESSAGES_MAXIMUM);
    int maxMessages = ((Integer) prop.getValue()).intValue();
    mq.setMaxMessages(maxMessages);
    prop = queueController.getProperty(QueueManagerImpl.PROP_PERSISTENCE);
    int pm = SwiftUtilities.persistenceModeToInt((String) prop.getValue());
    mq.setPersistenceMode(pm);
    prop = queueController.getProperty(QueueManagerImpl.PROP_FLOWCONTROL_QUEUE_SIZE);
    int fcQueueSize = ((Integer) prop.getValue()).intValue();
    if (fcQueueSize >= 0)
        mq.setFlowController(new FlowControllerImpl(fcQueueSize, ctx.queueManager.getMaxFlowControlDelay()));
    prop = queueController.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_ENABLED);
    mq.setDuplicateDetectionEnabled(((Boolean) prop.getValue()).booleanValue());
    prop = queueController.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_BACKLOG_SIZE);
    mq.setDuplicateDetectionBacklogSize(((Integer) prop.getValue()).intValue());
    prop = queueController.getProperty(QueueManagerImpl.PROP_CONSUMER);
    mq.setConsumerMode(ctx.consumerModeInt((String) prop.getValue()));
    mq.setQueueController(queueController);
    return mq;
}
Also used : NonPersistentStore(com.swiftmq.swiftlet.store.NonPersistentStore) PersistentStore(com.swiftmq.swiftlet.store.PersistentStore) QueueException(com.swiftmq.swiftlet.queue.QueueException) NonPersistentStore(com.swiftmq.swiftlet.store.NonPersistentStore) QueueException(com.swiftmq.swiftlet.queue.QueueException) Property(com.swiftmq.mgmt.Property)

Example 78 with Property

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

the class TempQueueFactory method createQueue.

public AbstractQueue createQueue(String queueName, Entity queueController) throws QueueException {
    NonPersistentStore nStore = null;
    try {
        nStore = ctx.storeSwiftlet.getNonPersistentStore(queueName);
    } catch (Exception e) {
        throw new QueueException(e.toString());
    }
    Property prop = queueController.getProperty(QueueManagerImpl.PROP_CACHE_SIZE);
    int cacheSize = ((Integer) prop.getValue()).intValue();
    prop = queueController.getProperty(QueueManagerImpl.PROP_CACHE_SIZE_BYTES_KB);
    int cacheSizeBytesKB = ((Integer) prop.getValue()).intValue();
    Cache cache = new CacheImpl(cacheSize, cacheSizeBytesKB, null, nStore);
    cache.setCacheTable(ctx.cacheTableFactory.createCacheTable(queueName, cacheSize));
    prop = queueController.getProperty(QueueManagerImpl.PROP_CLEANUP_INTERVAL);
    long cleanUp = ((Long) prop.getValue()).longValue();
    MessageQueue mq = ctx.messageQueueFactory.createMessageQueue(ctx, queueName, cache, null, nStore, cleanUp, myTP);
    prop = queueController.getProperty(QueueManagerImpl.PROP_MESSAGES_MAXIMUM);
    int maxMessages = ((Integer) prop.getValue()).intValue();
    mq.setMaxMessages(maxMessages);
    prop = queueController.getProperty(QueueManagerImpl.PROP_PERSISTENCE);
    int pm = SwiftUtilities.persistenceModeToInt((String) prop.getValue());
    mq.setPersistenceMode(pm);
    prop = queueController.getProperty(QueueManagerImpl.PROP_FLOWCONTROL_QUEUE_SIZE);
    int fcQueueSize = ((Integer) prop.getValue()).intValue();
    if (fcQueueSize >= 0)
        mq.setFlowController(new FlowControllerImpl(fcQueueSize, ctx.queueManager.getMaxFlowControlDelay()));
    prop = queueController.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_ENABLED);
    mq.setDuplicateDetectionEnabled(((Boolean) prop.getValue()).booleanValue());
    prop = queueController.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_BACKLOG_SIZE);
    mq.setDuplicateDetectionBacklogSize(((Integer) prop.getValue()).intValue());
    prop = queueController.getProperty(QueueManagerImpl.PROP_CONSUMER);
    mq.setConsumerMode(ctx.consumerModeInt((String) prop.getValue()));
    mq.setQueueController(queueController);
    return mq;
}
Also used : QueueException(com.swiftmq.swiftlet.queue.QueueException) NonPersistentStore(com.swiftmq.swiftlet.store.NonPersistentStore) QueueException(com.swiftmq.swiftlet.queue.QueueException) Property(com.swiftmq.mgmt.Property)

Example 79 with Property

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

the class MessageQueue method setQueueController.

void setQueueController(Entity queueController) {
    watchListeners = new ArrayList();
    Property prop = queueController.getProperty(QueueManagerImpl.PROP_CACHE_SIZE);
    PropertyWatchListener l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            cache.setMaxMessages(((Integer) property.getValue()).intValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_CACHE_SIZE_BYTES_KB);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            cache.setMaxBytesKB(((Integer) property.getValue()).intValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_CLEANUP_INTERVAL);
    prop = queueController.getProperty(QueueManagerImpl.PROP_MESSAGES_MAXIMUM);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setMaxMessages(((Integer) property.getValue()).intValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_PERSISTENCE);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setPersistenceMode(SwiftUtilities.persistenceModeToInt((String) property.getValue()));
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_FLOWCONTROL_QUEUE_SIZE);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            int fcQueueSize = ((Integer) property.getValue()).intValue();
            if (fcQueueSize >= 0)
                setFlowController(new FlowControllerImpl(fcQueueSize, ctx.queueManager.getMaxFlowControlDelay()));
            else
                setFlowController(null);
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_ENABLED);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setDuplicateDetectionEnabled(((Boolean) property.getValue()).booleanValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_BACKLOG_SIZE);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setDuplicateDetectionBacklogSize(((Integer) property.getValue()).intValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_CONSUMER);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setConsumerMode(ctx.consumerModeInt((String) property.getValue()));
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_MONITOR_ALERT_THRESHOLD);
    if (prop != null) {
        l = new PropertyWatchListener() {

            public void propertyValueChanged(Property property) {
                setMonitorAlertThreshold(((Integer) property.getValue()).intValue());
            }
        };
        prop.addPropertyWatchListener(l);
        watchListeners.add(new Object[] { prop, l });
    }
}
Also used : PropertyWatchListener(com.swiftmq.mgmt.PropertyWatchListener) Property(com.swiftmq.mgmt.Property)

Example 80 with Property

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

the class MessageQueue method removeWatchListeners.

private void removeWatchListeners() {
    if (watchListeners != null) {
        for (int i = 0; i < watchListeners.size(); i++) {
            Object[] obj = (Object[]) watchListeners.get(i);
            Property p = (Property) obj[0];
            PropertyWatchListener l = (PropertyWatchListener) obj[1];
            p.removePropertyWatchListener(l);
        }
        watchListeners = null;
    }
}
Also used : PropertyWatchListener(com.swiftmq.mgmt.PropertyWatchListener) Property(com.swiftmq.mgmt.Property)

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