use of com.swiftmq.mgmt.Property in project swiftmq-ce by iitsoftware.
the class MessageGroupDispatchPolicy method init.
private void init() {
Property prop = myEntity.getProperty("message-group-enabled");
enabled = ((Boolean) prop.getValue()).booleanValue();
prop.setPropertyChangeListener(new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
enabled = ((Boolean) newValue).booleanValue();
if (enabled)
restart();
else
reset();
}
});
prop = myEntity.getProperty("message-group-property");
propName = (String) prop.getValue();
prop.setPropertyChangeListener(new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
if (enabled)
throw new PropertyChangeException("Please disable message grouping for this clustered queue before you change this property!");
propName = (String) newValue;
}
});
prop = myEntity.getProperty("message-group-expiration");
expiration = ((Long) prop.getValue()).longValue();
prop.setPropertyChangeListener(new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
expiration = ((Long) newValue).longValue();
if (enabled && expiration != 0)
checkExpiration();
}
});
prop = myEntity.getProperty("message-group-expiration-cleanup-interval");
cleanupInterval = ((Long) prop.getValue()).longValue();
prop.setPropertyChangeListener(new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
cleanupInterval = changeCleanupInterval(((Long) newValue).longValue());
}
});
}
use of com.swiftmq.mgmt.Property in project swiftmq-ce by iitsoftware.
the class TransactedTopicSession method visit.
public void visit(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);
reply.setOk(true);
reply.setTopicSubscriberId(consumerId);
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);
}
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 + "/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);
}
reply.send();
}
use of com.swiftmq.mgmt.Property in project swiftmq-ce by iitsoftware.
the class TransactedUnifiedSession 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);
}
// enlist it at the transaction manager
transactionManager.addTransactionFactory(producer);
} 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();
}
use of com.swiftmq.mgmt.Property in project swiftmq-ce by iitsoftware.
the class TransactedUnifiedSession method visit.
public void visit(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);
}
}
reply.setOk(true);
reply.setTopicSubscriberId(consumerId);
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);
}
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 + "/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(e1);
}
reply.send();
}
use of com.swiftmq.mgmt.Property in project swiftmq-ce by iitsoftware.
the class BrowserManager method createBrowser.
public void createBrowser(CreateBrowserRequest request) {
CreateBrowserReply reply = (CreateBrowserReply) request.createReply();
QueueImpl queue = request.getQueue();
String messageSelector = request.getMessageSelector();
MessageSelector msel = null;
String queueName = null;
try {
queueName = queue.getQueueName();
} catch (JMSException ignored) {
}
try {
if (messageSelector != null) {
msel = new MessageSelector(messageSelector);
msel.compile();
}
if (!ctx.queueManager.isQueueRunning(queueName)) {
ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/" + toString() + ": Invalid destination: " + queueName);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + ": Invalid destination: " + queue);
reply.setOk(false);
reply.setException(new InvalidDestinationException("Invalid destination: " + queueName));
} else {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + ": Creating browser with selector: " + msel);
com.swiftmq.swiftlet.queue.QueueBrowser queueBrowser = ctx.queueManager.createQueueBrowser(queueName, ctx.activeLogin, msel);
int idx = ArrayListTool.setFirstFreeOrExpand(queueBrowsers, queueBrowser);
reply.setOk(true);
reply.setQueueBrowserId(idx);
if (browserEntityList != null) {
Entity browserEntity = browserEntityList.createEntity();
browserEntity.setName(queueName + "-" + idx);
browserEntity.setDynamicObject(queueBrowser);
browserEntity.createCommands();
Property prop = browserEntity.getProperty("queue");
prop.setValue(queueName);
prop.setReadOnly(true);
prop = browserEntity.getProperty("selector");
if (msel != null) {
prop.setValue(msel.getConditionString());
}
prop.setReadOnly(true);
browserEntityList.addEntity(browserEntity);
}
}
} catch (InvalidSelectorException e) {
ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/" + toString() + ": CreateBrowser has invalid Selector: " + e);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + ": CreateBrowser has invalid Selector: " + e);
reply.setOk(false);
reply.setException(e);
} catch (Exception e) {
ctx.logSwiftlet.logWarning("sys$jms", ctx.tracePrefix + "/" + toString() + ": Exception during createQueueBrowser: " + e);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + ": Exception during createQueueBrowser: " + e);
reply.setOk(false);
reply.setException(e);
}
reply.send();
}
Aggregations