use of com.swiftmq.swiftlet.auth.ResourceLimitException 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 {
if (!queueName.endsWith('@' + SwiftletManager.getInstance().getRouterName()))
throw new InvalidDestinationException("Queue '" + queueName + "' is not local! Can't create a Consumer on it!");
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();
}
use of com.swiftmq.swiftlet.auth.ResourceLimitException in project swiftmq-ce by iitsoftware.
the class NontransactedTopicSession 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);
}
}
consumer.setAutoCommit(req.isAutoCommit());
consumer.createReadTransaction();
consumer.createTransaction();
reply.setOk(true);
reply.setTopicSubscriberId(consumerId);
reply.setTmpQueueName((consumer).getQueueName());
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);
}
} 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 (req=" + req + "): \n" + SwiftUtilities.getStackTrace(e1));
reply.setOk(false);
reply.setException(e1);
}
reply.send();
}
use of com.swiftmq.swiftlet.auth.ResourceLimitException in project swiftmq-ce by iitsoftware.
the class NontransactedTopicSession 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);
consumer.createReadTransaction();
consumer.createTransaction();
reply.setOk(true);
reply.setTopicSubscriberId(consumerId);
reply.setQueueName(consumer.getQueueName() + '@' + SwiftletManager.getInstance().getRouterName());
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);
}
} 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.swiftlet.auth.ResourceLimitException in project swiftmq-ce by iitsoftware.
the class NontransactedUnifiedSession 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);
consumer.createReadTransaction();
consumer.createTransaction();
reply.setOk(true);
reply.setTopicSubscriberId(consumerId);
reply.setQueueName(consumer.getQueueName() + '@' + SwiftletManager.getInstance().getRouterName());
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);
}
} 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.swiftlet.auth.ResourceLimitException in project swiftmq-ce by iitsoftware.
the class NontransactedTopicSession 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);
consumer.createReadTransaction();
consumer.createTransaction();
reply.setOk(true);
reply.setTopicSubscriberId(consumerId);
reply.setQueueName(consumer.getQueueName() + '@' + SwiftletManager.getInstance().getRouterName());
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);
}
} 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();
}
Aggregations