use of com.swiftmq.jms.QueueImpl in project swiftmq-ce by iitsoftware.
the class QueueJNDIProcessor method run.
public void run() {
try {
t.commit();
try {
Versionable versionable = Versionable.toVersionable(msg);
int version = versionable.selectVersions(JNDISwiftletImpl.VERSIONS);
switch(version) {
case 400:
{
JNDIRequest r = (JNDIRequest) versionable.createVersionedObject();
com.swiftmq.impl.jndi.standard.v400.RequestVisitor visitor = new com.swiftmq.impl.jndi.standard.v400.RequestVisitor(ctx, (QueueImpl) msg.getJMSReplyTo(), true);
r.accept(visitor);
}
break;
default:
throw new Exception("Invalid version: " + version);
}
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.jndiSwiftlet.getName(), "QueueJNDIProcessor: exception occurred: " + e);
ctx.logSwiftlet.logError(ctx.jndiSwiftlet.getName(), "QueueJNDIProcessor: exception occurred: " + e);
}
msg = null;
if (closed)
return;
t = receiver.createTransaction(false);
t.registerMessageProcessor(this);
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.jndiSwiftlet.getName(), "QueueJNDIProcessor: exception occurred: " + e + ", EXITING!");
}
}
use of com.swiftmq.jms.QueueImpl in project swiftmq-ce by iitsoftware.
the class Listener method run.
public void run() {
try {
pullTransaction.commit();
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/run, exception committing tx: " + e + ", exiting");
return;
}
try {
BytesMessageImpl msg = (BytesMessageImpl) entry.getMessage();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/run, new message: " + msg);
QueueImpl queue = (QueueImpl) msg.getJMSReplyTo();
if (queue != null) {
int len = (int) msg.getBodyLength();
byte[] buffer = new byte[len];
msg.readBytes(buffer);
ctx.dispatchQueue.dispatchClientRequest(msg.getStringProperty(MessageImpl.PROP_USER_ID), queue.getQueueName(), buffer);
} else {
throw new Exception("Protocol error: Missing replyTo!");
}
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/run, exception during processing: " + e);
ctx.logSwiftlet.logError(ctx.mgmtSwiftlet.getName(), toString() + "/run, exception during processing: " + e);
}
if (closed)
return;
try {
pullTransaction = receiver.createTransaction(false);
pullTransaction.registerMessageProcessor(this);
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/run, exception creating new tx: " + e + ", exiting");
return;
}
}
use of com.swiftmq.jms.QueueImpl in project swiftmq-ce by iitsoftware.
the class MessageInterfaceListener method getReplyQueue.
private QueueImpl getReplyQueue(MessageImpl msg) throws JMSException {
QueueImpl queue = (QueueImpl) msg.getJMSReplyTo();
if (queue == null) {
if (msg.propertyExists(PROP_REPLY_QUEUE)) {
String name = msg.getStringProperty(PROP_REPLY_QUEUE);
queue = new QueueImpl(name);
}
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/getReplyQueue: " + queue);
return queue;
}
use of com.swiftmq.jms.QueueImpl in project swiftmq-ce by iitsoftware.
the class TopicJNDIProcessor method run.
public void run() {
try {
t.commit();
try {
Versionable versionable = Versionable.toVersionable(msg);
int version = versionable.selectVersions(JNDISwiftletImpl.VERSIONS);
switch(version) {
case 400:
{
JNDIRequest r = (JNDIRequest) versionable.createVersionedObject();
com.swiftmq.impl.jndi.standard.v400.RequestVisitor visitor = new com.swiftmq.impl.jndi.standard.v400.RequestVisitor(ctx, (QueueImpl) msg.getJMSReplyTo());
r.accept(visitor);
}
break;
default:
throw new Exception("Invalid version: " + version);
}
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.jndiSwiftlet.getName(), "TopicJNDIProcessor: exception occurred: " + e);
ctx.logSwiftlet.logError(ctx.jndiSwiftlet.getName(), "TopicJNDIProcessor: exception occurred: " + e);
}
msg = null;
if (closed)
return;
t = receiver.createTransaction(false);
t.registerMessageProcessor(this);
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.jndiSwiftlet.getName(), "TopicJNDIProcessor: exception occurred: " + e + ", EXITING!");
}
}
use of com.swiftmq.jms.QueueImpl 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();
}
Aggregations