Search in sources :

Example 1 with NonPersistentStore

use of com.swiftmq.swiftlet.store.NonPersistentStore 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 2 with NonPersistentStore

use of com.swiftmq.swiftlet.store.NonPersistentStore 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 3 with NonPersistentStore

use of com.swiftmq.swiftlet.store.NonPersistentStore 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)

Aggregations

Property (com.swiftmq.mgmt.Property)3 QueueException (com.swiftmq.swiftlet.queue.QueueException)3 NonPersistentStore (com.swiftmq.swiftlet.store.NonPersistentStore)3 PersistentStore (com.swiftmq.swiftlet.store.PersistentStore)2 PropertyChangeAdapter (com.swiftmq.mgmt.PropertyChangeAdapter)1 PropertyChangeException (com.swiftmq.mgmt.PropertyChangeException)1