use of com.swiftmq.mgmt.Property 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 {
queueName = validateDestination(queueName);
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.mgmt.Property in project swiftmq-ce by iitsoftware.
the class TransactedQueueSession 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 {
queueName = validateDestination(queueName);
int consumerId = 0;
QueueConsumer consumer = null;
consumerId = ArrayListTool.setFirstFreeOrExpand(consumerList, null);
consumer = new QueueConsumer(ctx, queueName, messageSelector);
consumerList.set(consumerId, consumer);
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);
}
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 + "/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.mgmt.Property in project swiftmq-ce by iitsoftware.
the class StableStore method init.
private void init() throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/init ...");
nFree = 0;
if (freePoolEnabled)
freePool = new IntRingBuffer[10];
filename = path + File.separatorChar + FILENAME;
emptyData = new byte[Page.PAGE_SIZE];
// emtpy
emptyData[0] = 1;
for (int i = 1; i < Page.PAGE_SIZE; i++) emptyData[i] = 0;
file = new RandomAccessFile(filename, "rw");
fileLength = file.length();
if (fileLength > 0) {
numberPages = (int) (fileLength / Page.PAGE_SIZE);
if (!offline)
shrinkFile();
} else
initialize(initialPages);
sync();
if (freePoolEnabled)
buildFreePageList();
if (!offline) {
Entity entity = ctx.filesList.createEntity();
entity.setName(FILENAME);
entity.createCommands();
ctx.filesList.addEntity(entity);
freeProp = entity.getProperty("free-pages");
usedProp = entity.getProperty("used-pages");
fileSizeProp = entity.getProperty("file-size");
sizeCollectProp = ctx.dbEntity.getProperty("size-collect-interval");
collectInterval = (long) (Long) sizeCollectProp.getValue();
startTimer();
PropertyChangeListener propChangeListener = new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
stopTimer();
collectInterval = (Long) newValue;
startTimer();
}
};
sizeCollectProp.setPropertyChangeListener(propChangeListener);
swiftletManagerAdapter = new SwiftletManagerAdapter() {
public void swiftletStarted(SwiftletManagerEvent event) {
mgmtSwiftlet = (MgmtSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$mgmt");
mgmtSwiftlet.addMgmtListener(StableStore.this);
}
};
SwiftletManager.getInstance().addSwiftletManagerListener("sys$mgmt", swiftletManagerAdapter);
}
ctx.logSwiftlet.logInformation("sys$store", toString() + "/init done, size=" + numberPages + ", freePages=" + getNumberFreePages());
}
use of com.swiftmq.mgmt.Property in project swiftmq-ce by iitsoftware.
the class JobGroupImpl method addJobFactory.
public synchronized void addJobFactory(String jobName, JobFactory jobFactory) {
if (!hasJobFactory(jobName)) {
Entity entity = jobList.createEntity();
entity.setName(jobFactory.getName());
entity.createCommands();
entity.setDynamic(true);
entity.setDynamicObject(jobFactory);
try {
Property prop = entity.getProperty("description");
prop.setReadOnly(false);
prop.setValue(jobFactory.getDescription());
prop.setReadOnly(true);
Map parmMap = jobFactory.getJobParameters();
if (parmMap != null) {
EntityList parmList = (EntityList) entity.getEntity("parameters");
for (Iterator iter = parmMap.entrySet().iterator(); iter.hasNext(); ) {
JobParameter parm = (JobParameter) ((Map.Entry) iter.next()).getValue();
Entity pe = parmList.createEntity();
pe.setName(parm.getName());
pe.setDynamic(true);
pe.createCommands();
pe.setDynamicObject(parm);
prop = pe.getProperty("description");
prop.setReadOnly(false);
prop.setValue(parm.getDescription());
prop.setReadOnly(true);
prop = pe.getProperty("default");
prop.setReadOnly(false);
prop.setValue(parm.getDefaultValue());
prop.setReadOnly(true);
prop = pe.getProperty("mandatory");
prop.setReadOnly(false);
prop.setValue(new Boolean(parm.isMandatory()));
prop.setReadOnly(true);
parmList.addEntity(pe);
}
}
jobList.addEntity(entity);
ctx.scheduler.enqueue(new JobFactoryAdded(name, jobName, jobFactory));
} catch (Exception e) {
}
}
}
use of com.swiftmq.mgmt.Property in project swiftmq-ce by iitsoftware.
the class NontransactedQueueSession 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);
}
} 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();
}
Aggregations