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;
}
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;
}
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;
}
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 });
}
}
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;
}
}
Aggregations