Search in sources :

Example 41 with QueueImpl

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!");
    }
}
Also used : JNDIRequest(com.swiftmq.jndi.protocol.v400.JNDIRequest) QueueImpl(com.swiftmq.jms.QueueImpl) Versionable(com.swiftmq.tools.versioning.Versionable)

Example 42 with QueueImpl

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;
    }
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) QueueImpl(com.swiftmq.jms.QueueImpl)

Example 43 with QueueImpl

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;
}
Also used : QueueImpl(com.swiftmq.jms.QueueImpl)

Example 44 with QueueImpl

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!");
    }
}
Also used : JNDIRequest(com.swiftmq.jndi.protocol.v400.JNDIRequest) QueueImpl(com.swiftmq.jms.QueueImpl) Versionable(com.swiftmq.tools.versioning.Versionable)

Example 45 with QueueImpl

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();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) JMSException(javax.jms.JMSException) Property(com.swiftmq.mgmt.Property) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) QueueImpl(com.swiftmq.jms.QueueImpl) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException)

Aggregations

QueueImpl (com.swiftmq.jms.QueueImpl)78 InvalidSelectorException (javax.jms.InvalidSelectorException)51 JMSException (javax.jms.JMSException)51 InvalidDestinationException (javax.jms.InvalidDestinationException)49 ResourceLimitException (com.swiftmq.swiftlet.auth.ResourceLimitException)42 Entity (com.swiftmq.mgmt.Entity)35 Property (com.swiftmq.mgmt.Property)35 MessageImpl (com.swiftmq.jms.MessageImpl)21 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)16 MessageSelector (com.swiftmq.ms.MessageSelector)9 RingBuffer (com.swiftmq.tools.collection.RingBuffer)7 DataByteArrayInputStream (com.swiftmq.tools.util.DataByteArrayInputStream)7 List (java.util.List)6 EntityList (com.swiftmq.mgmt.EntityList)5 BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)4 TopicImpl (com.swiftmq.jms.TopicImpl)4 SwiftletException (com.swiftmq.swiftlet.SwiftletException)3 TextMessageImpl (com.swiftmq.jms.TextMessageImpl)2 JNDIRequest (com.swiftmq.jndi.protocol.v400.JNDIRequest)2 AuthenticationException (com.swiftmq.swiftlet.auth.AuthenticationException)2