Search in sources :

Example 1 with QueueImpl

use of com.swiftmq.jms.QueueImpl in project swiftmq-ce by iitsoftware.

the class QueueMemory method add.

@Override
public Memory add(Message message) throws Exception {
    if (ctx.ctx.traceSpace.enabled)
        ctx.ctx.traceSpace.trace(ctx.ctx.streamsSwiftlet.getName(), toString() + "/add ...");
    if (isLate(message))
        return this;
    String key = message.messageId();
    if (key == null)
        key = ctx.nextId();
    if (messageStore.get(key) != null) {
        // Duplicate!
        return this;
    }
    long storeTime = getStoreTime(message);
    checkLimit();
    KeyEntry keyEntry = new KeyEntry(key, null, storeTime);
    messageStore.add(key, keyEntry);
    Message copy = ctx.messageBuilder.copyMessage(message);
    MessageImpl impl = copy.getImpl();
    if (impl.getJMSDestination() == null)
        impl.setJMSDestination(new QueueImpl(queueName));
    // Important for the ordering
    impl.setJMSPriority(0);
    impl.setJMSDeliveryMode(getDeliveryMode());
    impl.setJMSTimestamp(storeTime);
    if (key.startsWith("ID:"))
        impl.setJMSMessageID(key.substring(3));
    else
        impl.setJMSMessageID(key);
    if (shared)
        impl.setStringProperty(KEY, name);
    txBookKeeper.add(key, copy, keyEntry);
    addToIndexes(key, copy);
    if (ctx.ctx.traceSpace.enabled)
        ctx.ctx.traceSpace.trace(ctx.ctx.streamsSwiftlet.getName(), toString() + "/add done");
    return this;
}
Also used : Message(com.swiftmq.impl.streams.comp.message.Message) MessageImpl(com.swiftmq.jms.MessageImpl) QueueImpl(com.swiftmq.jms.QueueImpl)

Example 2 with QueueImpl

use of com.swiftmq.jms.QueueImpl in project swiftmq-client by iitsoftware.

the class SwiftMQObjectFactory method getObjectInstance.

public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception {
    if (obj instanceof Reference) {
        Reference ref = (Reference) obj;
        if (ref.getClassName().equals(TopicImpl.class.getName())) {
            RefAddr addr = ref.get("topicName");
            if (addr != null) {
                return new TopicImpl((String) addr.getContent());
            }
        } else if (ref.getClassName().equals(QueueImpl.class.getName())) {
            RefAddr addr = ref.get("queueName");
            if (addr != null) {
                return new QueueImpl((String) addr.getContent());
            }
        } else if (ref.getClassName().equals(com.swiftmq.jms.v400.ConnectionFactoryImpl.class.getName())) {
            RefAddr listenerName = ref.get("listenerName");
            RefAddr socketFactoryClass = ref.get("socketFactoryClass");
            RefAddr hostname = ref.get("hostname");
            RefAddr port = ref.get("port");
            RefAddr keepaliveInterval = ref.get("keepaliveInterval");
            RefAddr clientId = ref.get("clientId");
            RefAddr smqpProducerReplyInterval = ref.get("smqpProducerReplyInterval");
            RefAddr smqpConsumerCacheSize = ref.get("smqpConsumerCacheSize");
            RefAddr jmsDeliveryMode = ref.get("jmsDeliveryMode");
            RefAddr jmsPriority = ref.get("jmsPriority");
            RefAddr jmsTTL = ref.get("jmsTTL");
            RefAddr jmsMessageIdEnabled = ref.get("jmsMessageIdEnabled");
            RefAddr jmsMessageTimestampEnabled = ref.get("jmsMessageTimestampEnabled");
            RefAddr useThreadContextCL = ref.get("useThreadContextCL");
            RefAddr inputBufferSize = ref.get("inputBufferSize");
            RefAddr inputExtendSize = ref.get("inputExtendSize");
            RefAddr outputBufferSize = ref.get("outputBufferSize");
            RefAddr outputExtendSize = ref.get("outputExtendSize");
            RefAddr intraVM = ref.get("intraVM");
            if (listenerName != null && socketFactoryClass != null && hostname != null && port != null && keepaliveInterval != null && smqpProducerReplyInterval != null && smqpConsumerCacheSize != null && jmsDeliveryMode != null && jmsPriority != null && jmsTTL != null && jmsMessageIdEnabled != null && jmsMessageTimestampEnabled != null && useThreadContextCL != null && inputBufferSize != null && inputExtendSize != null && outputBufferSize != null && outputExtendSize != null && intraVM != null) {
                com.swiftmq.jms.v400.ConnectionFactoryImpl cf = new com.swiftmq.jms.v400.ConnectionFactoryImpl((String) listenerName.getContent(), (String) socketFactoryClass.getContent(), (String) hostname.getContent(), Integer.parseInt((String) port.getContent()), Long.parseLong((String) keepaliveInterval.getContent()), clientId == null ? null : (String) clientId.getContent(), Integer.parseInt((String) smqpProducerReplyInterval.getContent()), Integer.parseInt((String) smqpConsumerCacheSize.getContent()), Integer.parseInt((String) jmsDeliveryMode.getContent()), Integer.parseInt((String) jmsPriority.getContent()), Long.parseLong((String) jmsTTL.getContent()), Boolean.valueOf((String) jmsMessageIdEnabled.getContent()).booleanValue(), Boolean.valueOf((String) jmsMessageTimestampEnabled.getContent()).booleanValue(), Boolean.valueOf((String) useThreadContextCL.getContent()).booleanValue(), Integer.parseInt((String) inputBufferSize.getContent()), Integer.parseInt((String) inputExtendSize.getContent()), Integer.parseInt((String) outputBufferSize.getContent()), Integer.parseInt((String) outputExtendSize.getContent()), Boolean.valueOf((String) intraVM.getContent()).booleanValue());
                return cf;
            }
        } else if (ref.getClassName().equals(com.swiftmq.jms.v500.ConnectionFactoryImpl.class.getName())) {
            RefAddr listenerName = ref.get("listenerName");
            RefAddr socketFactoryClass = ref.get("socketFactoryClass");
            RefAddr hostname = ref.get("hostname");
            RefAddr port = ref.get("port");
            RefAddr keepaliveInterval = ref.get("keepaliveInterval");
            RefAddr clientId = ref.get("clientId");
            RefAddr smqpProducerReplyInterval = ref.get("smqpProducerReplyInterval");
            RefAddr smqpConsumerCacheSize = ref.get("smqpConsumerCacheSize");
            RefAddr jmsDeliveryMode = ref.get("jmsDeliveryMode");
            RefAddr jmsPriority = ref.get("jmsPriority");
            RefAddr jmsTTL = ref.get("jmsTTL");
            RefAddr jmsMessageIdEnabled = ref.get("jmsMessageIdEnabled");
            RefAddr jmsMessageTimestampEnabled = ref.get("jmsMessageTimestampEnabled");
            RefAddr useThreadContextCL = ref.get("useThreadContextCL");
            RefAddr inputBufferSize = ref.get("inputBufferSize");
            RefAddr inputExtendSize = ref.get("inputExtendSize");
            RefAddr outputBufferSize = ref.get("outputBufferSize");
            RefAddr outputExtendSize = ref.get("outputExtendSize");
            RefAddr intraVM = ref.get("intraVM");
            if (listenerName != null && socketFactoryClass != null && hostname != null && port != null && keepaliveInterval != null && smqpProducerReplyInterval != null && smqpConsumerCacheSize != null && jmsDeliveryMode != null && jmsPriority != null && jmsTTL != null && jmsMessageIdEnabled != null && jmsMessageTimestampEnabled != null && useThreadContextCL != null && inputBufferSize != null && inputExtendSize != null && outputBufferSize != null && outputExtendSize != null && intraVM != null) {
                com.swiftmq.jms.v500.ConnectionFactoryImpl cf = new com.swiftmq.jms.v500.ConnectionFactoryImpl((String) listenerName.getContent(), (String) socketFactoryClass.getContent(), (String) hostname.getContent(), Integer.parseInt((String) port.getContent()), Long.parseLong((String) keepaliveInterval.getContent()), clientId == null ? null : (String) clientId.getContent(), Integer.parseInt((String) smqpProducerReplyInterval.getContent()), Integer.parseInt((String) smqpConsumerCacheSize.getContent()), Integer.parseInt((String) jmsDeliveryMode.getContent()), Integer.parseInt((String) jmsPriority.getContent()), Long.parseLong((String) jmsTTL.getContent()), Boolean.valueOf((String) jmsMessageIdEnabled.getContent()).booleanValue(), Boolean.valueOf((String) jmsMessageTimestampEnabled.getContent()).booleanValue(), Boolean.valueOf((String) useThreadContextCL.getContent()).booleanValue(), Integer.parseInt((String) inputBufferSize.getContent()), Integer.parseInt((String) inputExtendSize.getContent()), Integer.parseInt((String) outputBufferSize.getContent()), Integer.parseInt((String) outputExtendSize.getContent()), Boolean.valueOf((String) intraVM.getContent()).booleanValue());
                return cf;
            }
        } else if (ref.getClassName().equals(com.swiftmq.jms.v510.ConnectionFactoryImpl.class.getName())) {
            RefAddr listenerName = ref.get("listenerName");
            RefAddr socketFactoryClass = ref.get("socketFactoryClass");
            RefAddr hostname = ref.get("hostname");
            RefAddr port = ref.get("port");
            RefAddr keepaliveInterval = ref.get("keepaliveInterval");
            RefAddr clientId = ref.get("clientId");
            RefAddr smqpProducerReplyInterval = ref.get("smqpProducerReplyInterval");
            RefAddr smqpConsumerCacheSize = ref.get("smqpConsumerCacheSize");
            RefAddr jmsDeliveryMode = ref.get("jmsDeliveryMode");
            RefAddr jmsPriority = ref.get("jmsPriority");
            RefAddr jmsTTL = ref.get("jmsTTL");
            RefAddr jmsMessageIdEnabled = ref.get("jmsMessageIdEnabled");
            RefAddr jmsMessageTimestampEnabled = ref.get("jmsMessageTimestampEnabled");
            RefAddr useThreadContextCL = ref.get("useThreadContextCL");
            RefAddr inputBufferSize = ref.get("inputBufferSize");
            RefAddr inputExtendSize = ref.get("inputExtendSize");
            RefAddr outputBufferSize = ref.get("outputBufferSize");
            RefAddr outputExtendSize = ref.get("outputExtendSize");
            RefAddr intraVM = ref.get("intraVM");
            if (listenerName != null && socketFactoryClass != null && hostname != null && port != null && keepaliveInterval != null && smqpProducerReplyInterval != null && smqpConsumerCacheSize != null && jmsDeliveryMode != null && jmsPriority != null && jmsTTL != null && jmsMessageIdEnabled != null && jmsMessageTimestampEnabled != null && useThreadContextCL != null && inputBufferSize != null && inputExtendSize != null && outputBufferSize != null && outputExtendSize != null && intraVM != null) {
                com.swiftmq.jms.v510.ConnectionFactoryImpl cf = new com.swiftmq.jms.v510.ConnectionFactoryImpl((String) listenerName.getContent(), (String) socketFactoryClass.getContent(), (String) hostname.getContent(), Integer.parseInt((String) port.getContent()), Long.parseLong((String) keepaliveInterval.getContent()), clientId == null ? null : (String) clientId.getContent(), Integer.parseInt((String) smqpProducerReplyInterval.getContent()), Integer.parseInt((String) smqpConsumerCacheSize.getContent()), Integer.parseInt((String) jmsDeliveryMode.getContent()), Integer.parseInt((String) jmsPriority.getContent()), Long.parseLong((String) jmsTTL.getContent()), Boolean.valueOf((String) jmsMessageIdEnabled.getContent()).booleanValue(), Boolean.valueOf((String) jmsMessageTimestampEnabled.getContent()).booleanValue(), Boolean.valueOf((String) useThreadContextCL.getContent()).booleanValue(), Integer.parseInt((String) inputBufferSize.getContent()), Integer.parseInt((String) inputExtendSize.getContent()), Integer.parseInt((String) outputBufferSize.getContent()), Integer.parseInt((String) outputExtendSize.getContent()), Boolean.valueOf((String) intraVM.getContent()).booleanValue());
                return cf;
            }
        } else if (ref.getClassName().equals(com.swiftmq.jms.v600.ConnectionFactoryImpl.class.getName())) {
            RefAddr listenerName = ref.get("listenerName");
            RefAddr socketFactoryClass = ref.get("socketFactoryClass");
            RefAddr hostname = ref.get("hostname");
            RefAddr port = ref.get("port");
            RefAddr keepaliveInterval = ref.get("keepaliveInterval");
            RefAddr clientId = ref.get("clientId");
            RefAddr smqpProducerReplyInterval = ref.get("smqpProducerReplyInterval");
            RefAddr smqpConsumerCacheSize = ref.get("smqpConsumerCacheSize");
            RefAddr jmsDeliveryMode = ref.get("jmsDeliveryMode");
            RefAddr jmsPriority = ref.get("jmsPriority");
            RefAddr jmsTTL = ref.get("jmsTTL");
            RefAddr jmsMessageIdEnabled = ref.get("jmsMessageIdEnabled");
            RefAddr jmsMessageTimestampEnabled = ref.get("jmsMessageTimestampEnabled");
            RefAddr useThreadContextCL = ref.get("useThreadContextCL");
            RefAddr inputBufferSize = ref.get("inputBufferSize");
            RefAddr inputExtendSize = ref.get("inputExtendSize");
            RefAddr outputBufferSize = ref.get("outputBufferSize");
            RefAddr outputExtendSize = ref.get("outputExtendSize");
            RefAddr intraVM = ref.get("intraVM");
            RefAddr hostname2 = ref.get("hostname2");
            RefAddr port2 = ref.get("port2");
            RefAddr reconnectEnabled = ref.get("reconnectEnabled");
            RefAddr maxRetries = ref.get("maxRetries");
            RefAddr retryDelay = ref.get("retryDelay");
            RefAddr duplicateMessageDetection = ref.get("duplicateMessageDetection");
            RefAddr duplicateBacklogSize = ref.get("duplicateBacklogSize");
            if (listenerName != null && socketFactoryClass != null && hostname != null && port != null && keepaliveInterval != null && smqpProducerReplyInterval != null && smqpConsumerCacheSize != null && jmsDeliveryMode != null && jmsPriority != null && jmsTTL != null && jmsMessageIdEnabled != null && jmsMessageTimestampEnabled != null && useThreadContextCL != null && inputBufferSize != null && inputExtendSize != null && outputBufferSize != null && outputExtendSize != null && intraVM != null) {
                com.swiftmq.jms.v600.ConnectionFactoryImpl cf = new com.swiftmq.jms.v600.ConnectionFactoryImpl((String) listenerName.getContent(), (String) socketFactoryClass.getContent(), (String) hostname.getContent(), Integer.parseInt((String) port.getContent()), Long.parseLong((String) keepaliveInterval.getContent()), clientId == null ? null : (String) clientId.getContent(), Integer.parseInt((String) smqpProducerReplyInterval.getContent()), Integer.parseInt((String) smqpConsumerCacheSize.getContent()), Integer.parseInt((String) jmsDeliveryMode.getContent()), Integer.parseInt((String) jmsPriority.getContent()), Long.parseLong((String) jmsTTL.getContent()), Boolean.valueOf((String) jmsMessageIdEnabled.getContent()).booleanValue(), Boolean.valueOf((String) jmsMessageTimestampEnabled.getContent()).booleanValue(), Boolean.valueOf((String) useThreadContextCL.getContent()).booleanValue(), Integer.parseInt((String) inputBufferSize.getContent()), Integer.parseInt((String) inputExtendSize.getContent()), Integer.parseInt((String) outputBufferSize.getContent()), Integer.parseInt((String) outputExtendSize.getContent()), Boolean.valueOf((String) intraVM.getContent()).booleanValue());
                cf.setReconnectEnabled(Boolean.valueOf((String) reconnectEnabled.getContent()).booleanValue());
                cf.setMaxRetries(Integer.valueOf((String) maxRetries.getContent()).intValue());
                cf.setRetryDelay(Long.valueOf((String) retryDelay.getContent()).longValue());
                cf.setDuplicateMessageDetection(Boolean.valueOf((String) duplicateMessageDetection.getContent()).booleanValue());
                cf.setDuplicateBacklogSize(Integer.valueOf((String) duplicateBacklogSize.getContent()).intValue());
                if (hostname2 != null) {
                    cf.setHostname2((String) hostname2.getContent());
                    cf.setPort2(Integer.parseInt((String) port2.getContent()));
                }
                return cf;
            }
        } else if (ref.getClassName().equals(com.swiftmq.jms.v610.ConnectionFactoryImpl.class.getName())) {
            RefAddr listenerName = ref.get("listenerName");
            RefAddr socketFactoryClass = ref.get("socketFactoryClass");
            RefAddr hostname = ref.get("hostname");
            RefAddr port = ref.get("port");
            RefAddr keepaliveInterval = ref.get("keepaliveInterval");
            RefAddr clientId = ref.get("clientId");
            RefAddr smqpProducerReplyInterval = ref.get("smqpProducerReplyInterval");
            RefAddr smqpConsumerCacheSize = ref.get("smqpConsumerCacheSize");
            RefAddr jmsDeliveryMode = ref.get("jmsDeliveryMode");
            RefAddr jmsPriority = ref.get("jmsPriority");
            RefAddr jmsTTL = ref.get("jmsTTL");
            RefAddr jmsMessageIdEnabled = ref.get("jmsMessageIdEnabled");
            RefAddr jmsMessageTimestampEnabled = ref.get("jmsMessageTimestampEnabled");
            RefAddr useThreadContextCL = ref.get("useThreadContextCL");
            RefAddr inputBufferSize = ref.get("inputBufferSize");
            RefAddr inputExtendSize = ref.get("inputExtendSize");
            RefAddr outputBufferSize = ref.get("outputBufferSize");
            RefAddr outputExtendSize = ref.get("outputExtendSize");
            RefAddr intraVM = ref.get("intraVM");
            RefAddr hostname2 = ref.get("hostname2");
            RefAddr port2 = ref.get("port2");
            RefAddr reconnectEnabled = ref.get("reconnectEnabled");
            RefAddr maxRetries = ref.get("maxRetries");
            RefAddr retryDelay = ref.get("retryDelay");
            RefAddr duplicateMessageDetection = ref.get("duplicateMessageDetection");
            RefAddr duplicateBacklogSize = ref.get("duplicateBacklogSize");
            if (listenerName != null && socketFactoryClass != null && hostname != null && port != null && keepaliveInterval != null && smqpProducerReplyInterval != null && smqpConsumerCacheSize != null && jmsDeliveryMode != null && jmsPriority != null && jmsTTL != null && jmsMessageIdEnabled != null && jmsMessageTimestampEnabled != null && useThreadContextCL != null && inputBufferSize != null && inputExtendSize != null && outputBufferSize != null && outputExtendSize != null && intraVM != null) {
                com.swiftmq.jms.v610.ConnectionFactoryImpl cf = new com.swiftmq.jms.v610.ConnectionFactoryImpl((String) listenerName.getContent(), (String) socketFactoryClass.getContent(), (String) hostname.getContent(), Integer.parseInt((String) port.getContent()), Long.parseLong((String) keepaliveInterval.getContent()), clientId == null ? null : (String) clientId.getContent(), Integer.parseInt((String) smqpProducerReplyInterval.getContent()), Integer.parseInt((String) smqpConsumerCacheSize.getContent()), Integer.parseInt((String) jmsDeliveryMode.getContent()), Integer.parseInt((String) jmsPriority.getContent()), Long.parseLong((String) jmsTTL.getContent()), Boolean.valueOf((String) jmsMessageIdEnabled.getContent()).booleanValue(), Boolean.valueOf((String) jmsMessageTimestampEnabled.getContent()).booleanValue(), Boolean.valueOf((String) useThreadContextCL.getContent()).booleanValue(), Integer.parseInt((String) inputBufferSize.getContent()), Integer.parseInt((String) inputExtendSize.getContent()), Integer.parseInt((String) outputBufferSize.getContent()), Integer.parseInt((String) outputExtendSize.getContent()), Boolean.valueOf((String) intraVM.getContent()).booleanValue());
                cf.setReconnectEnabled(Boolean.valueOf((String) reconnectEnabled.getContent()).booleanValue());
                cf.setMaxRetries(Integer.valueOf((String) maxRetries.getContent()).intValue());
                cf.setRetryDelay(Long.valueOf((String) retryDelay.getContent()).longValue());
                cf.setDuplicateMessageDetection(Boolean.valueOf((String) duplicateMessageDetection.getContent()).booleanValue());
                cf.setDuplicateBacklogSize(Integer.valueOf((String) duplicateBacklogSize.getContent()).intValue());
                if (hostname2 != null) {
                    cf.setHostname2((String) hostname2.getContent());
                    cf.setPort2(Integer.parseInt((String) port2.getContent()));
                }
                return cf;
            }
        } else if (ref.getClassName().equals(com.swiftmq.jms.v630.ConnectionFactoryImpl.class.getName())) {
            RefAddr listenerName = ref.get("listenerName");
            RefAddr socketFactoryClass = ref.get("socketFactoryClass");
            RefAddr hostname = ref.get("hostname");
            RefAddr port = ref.get("port");
            RefAddr keepaliveInterval = ref.get("keepaliveInterval");
            RefAddr clientId = ref.get("clientId");
            RefAddr smqpProducerReplyInterval = ref.get("smqpProducerReplyInterval");
            RefAddr smqpConsumerCacheSize = ref.get("smqpConsumerCacheSize");
            RefAddr jmsDeliveryMode = ref.get("jmsDeliveryMode");
            RefAddr jmsPriority = ref.get("jmsPriority");
            RefAddr jmsTTL = ref.get("jmsTTL");
            RefAddr jmsMessageIdEnabled = ref.get("jmsMessageIdEnabled");
            RefAddr jmsMessageTimestampEnabled = ref.get("jmsMessageTimestampEnabled");
            RefAddr useThreadContextCL = ref.get("useThreadContextCL");
            RefAddr inputBufferSize = ref.get("inputBufferSize");
            RefAddr inputExtendSize = ref.get("inputExtendSize");
            RefAddr outputBufferSize = ref.get("outputBufferSize");
            RefAddr outputExtendSize = ref.get("outputExtendSize");
            RefAddr intraVM = ref.get("intraVM");
            RefAddr hostname2 = ref.get("hostname2");
            RefAddr port2 = ref.get("port2");
            RefAddr reconnectEnabled = ref.get("reconnectEnabled");
            RefAddr maxRetries = ref.get("maxRetries");
            RefAddr retryDelay = ref.get("retryDelay");
            RefAddr duplicateMessageDetection = ref.get("duplicateMessageDetection");
            RefAddr duplicateBacklogSize = ref.get("duplicateBacklogSize");
            if (listenerName != null && socketFactoryClass != null && hostname != null && port != null && keepaliveInterval != null && smqpProducerReplyInterval != null && smqpConsumerCacheSize != null && jmsDeliveryMode != null && jmsPriority != null && jmsTTL != null && jmsMessageIdEnabled != null && jmsMessageTimestampEnabled != null && useThreadContextCL != null && inputBufferSize != null && inputExtendSize != null && outputBufferSize != null && outputExtendSize != null && intraVM != null) {
                com.swiftmq.jms.v630.ConnectionFactoryImpl cf = new com.swiftmq.jms.v630.ConnectionFactoryImpl((String) listenerName.getContent(), (String) socketFactoryClass.getContent(), (String) hostname.getContent(), Integer.parseInt((String) port.getContent()), Long.parseLong((String) keepaliveInterval.getContent()), clientId == null ? null : (String) clientId.getContent(), Integer.parseInt((String) smqpProducerReplyInterval.getContent()), Integer.parseInt((String) smqpConsumerCacheSize.getContent()), Integer.parseInt((String) jmsDeliveryMode.getContent()), Integer.parseInt((String) jmsPriority.getContent()), Long.parseLong((String) jmsTTL.getContent()), Boolean.valueOf((String) jmsMessageIdEnabled.getContent()).booleanValue(), Boolean.valueOf((String) jmsMessageTimestampEnabled.getContent()).booleanValue(), Boolean.valueOf((String) useThreadContextCL.getContent()).booleanValue(), Integer.parseInt((String) inputBufferSize.getContent()), Integer.parseInt((String) inputExtendSize.getContent()), Integer.parseInt((String) outputBufferSize.getContent()), Integer.parseInt((String) outputExtendSize.getContent()), Boolean.valueOf((String) intraVM.getContent()).booleanValue());
                cf.setReconnectEnabled(Boolean.valueOf((String) reconnectEnabled.getContent()).booleanValue());
                cf.setMaxRetries(Integer.valueOf((String) maxRetries.getContent()).intValue());
                cf.setRetryDelay(Long.valueOf((String) retryDelay.getContent()).longValue());
                cf.setDuplicateMessageDetection(Boolean.valueOf((String) duplicateMessageDetection.getContent()).booleanValue());
                cf.setDuplicateBacklogSize(Integer.valueOf((String) duplicateBacklogSize.getContent()).intValue());
                if (hostname2 != null) {
                    cf.setHostname2((String) hostname2.getContent());
                    cf.setPort2(Integer.parseInt((String) port2.getContent()));
                }
                return cf;
            }
        } else if (ref.getClassName().equals(com.swiftmq.jms.v750.ConnectionFactoryImpl.class.getName())) {
            RefAddr listenerName = ref.get("listenerName");
            RefAddr socketFactoryClass = ref.get("socketFactoryClass");
            RefAddr hostname = ref.get("hostname");
            RefAddr port = ref.get("port");
            RefAddr keepaliveInterval = ref.get("keepaliveInterval");
            RefAddr clientId = ref.get("clientId");
            RefAddr smqpProducerReplyInterval = ref.get("smqpProducerReplyInterval");
            RefAddr smqpConsumerCacheSize = ref.get("smqpConsumerCacheSize");
            RefAddr smqpConsumerCacheSizeKB = ref.get("smqpConsumerCacheSizeKB");
            RefAddr jmsDeliveryMode = ref.get("jmsDeliveryMode");
            RefAddr jmsPriority = ref.get("jmsPriority");
            RefAddr jmsTTL = ref.get("jmsTTL");
            RefAddr jmsMessageIdEnabled = ref.get("jmsMessageIdEnabled");
            RefAddr jmsMessageTimestampEnabled = ref.get("jmsMessageTimestampEnabled");
            RefAddr useThreadContextCL = ref.get("useThreadContextCL");
            RefAddr inputBufferSize = ref.get("inputBufferSize");
            RefAddr inputExtendSize = ref.get("inputExtendSize");
            RefAddr outputBufferSize = ref.get("outputBufferSize");
            RefAddr outputExtendSize = ref.get("outputExtendSize");
            RefAddr intraVM = ref.get("intraVM");
            RefAddr hostname2 = ref.get("hostname2");
            RefAddr port2 = ref.get("port2");
            RefAddr reconnectEnabled = ref.get("reconnectEnabled");
            RefAddr maxRetries = ref.get("maxRetries");
            RefAddr retryDelay = ref.get("retryDelay");
            RefAddr duplicateMessageDetection = ref.get("duplicateMessageDetection");
            RefAddr duplicateBacklogSize = ref.get("duplicateBacklogSize");
            if (listenerName != null && socketFactoryClass != null && hostname != null && port != null && keepaliveInterval != null && smqpProducerReplyInterval != null && smqpConsumerCacheSize != null && smqpConsumerCacheSizeKB != null && jmsDeliveryMode != null && jmsPriority != null && jmsTTL != null && jmsMessageIdEnabled != null && jmsMessageTimestampEnabled != null && useThreadContextCL != null && inputBufferSize != null && inputExtendSize != null && outputBufferSize != null && outputExtendSize != null && intraVM != null) {
                com.swiftmq.jms.v750.ConnectionFactoryImpl cf = new com.swiftmq.jms.v750.ConnectionFactoryImpl((String) listenerName.getContent(), (String) socketFactoryClass.getContent(), (String) hostname.getContent(), Integer.parseInt((String) port.getContent()), Long.parseLong((String) keepaliveInterval.getContent()), clientId == null ? null : (String) clientId.getContent(), Integer.parseInt((String) smqpProducerReplyInterval.getContent()), Integer.parseInt((String) smqpConsumerCacheSize.getContent()), Integer.parseInt((String) smqpConsumerCacheSizeKB.getContent()), Integer.parseInt((String) jmsDeliveryMode.getContent()), Integer.parseInt((String) jmsPriority.getContent()), Long.parseLong((String) jmsTTL.getContent()), Boolean.valueOf((String) jmsMessageIdEnabled.getContent()).booleanValue(), Boolean.valueOf((String) jmsMessageTimestampEnabled.getContent()).booleanValue(), Boolean.valueOf((String) useThreadContextCL.getContent()).booleanValue(), Integer.parseInt((String) inputBufferSize.getContent()), Integer.parseInt((String) inputExtendSize.getContent()), Integer.parseInt((String) outputBufferSize.getContent()), Integer.parseInt((String) outputExtendSize.getContent()), Boolean.valueOf((String) intraVM.getContent()).booleanValue());
                cf.setReconnectEnabled(Boolean.valueOf((String) reconnectEnabled.getContent()).booleanValue());
                cf.setMaxRetries(Integer.valueOf((String) maxRetries.getContent()).intValue());
                cf.setRetryDelay(Long.valueOf((String) retryDelay.getContent()).longValue());
                cf.setDuplicateMessageDetection(Boolean.valueOf((String) duplicateMessageDetection.getContent()).booleanValue());
                cf.setDuplicateBacklogSize(Integer.valueOf((String) duplicateBacklogSize.getContent()).intValue());
                if (hostname2 != null) {
                    cf.setHostname2((String) hostname2.getContent());
                    cf.setPort2(Integer.parseInt((String) port2.getContent()));
                }
                return cf;
            }
        }
    }
    return null;
}
Also used : Reference(javax.naming.Reference) QueueImpl(com.swiftmq.jms.QueueImpl) RefAddr(javax.naming.RefAddr) TopicImpl(com.swiftmq.jms.TopicImpl)

Example 3 with QueueImpl

use of com.swiftmq.jms.QueueImpl in project swiftmq-ce by iitsoftware.

the class NontransactedQueueSession method visit.

public void visit(ProduceMessageRequest req) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitProduceMessageRequest");
    ctx.incMsgsSent(1);
    ProduceMessageReply reply = null;
    if (req.isReplyRequired())
        reply = (ProduceMessageReply) req.createReply();
    int producerId = req.getQueueProducerId();
    Producer producer = null;
    try {
        MessageImpl msg = SMQPUtil.getMessage(req);
        if (producerId == -1) {
            String queueName = ((QueueImpl) msg.getJMSDestination()).getQueueName();
            if (!ctx.queueManager.isQueueRunning(queueName))
                throw new InvalidDestinationException("Invalid destination: " + queueName);
            producer = new QueueProducer(ctx, queueName);
        } else {
            producer = (Producer) producerList.get(producerId);
        }
        QueuePushTransaction transaction = (QueuePushTransaction) producer.createTransaction();
        transaction.putMessage(msg);
        transaction.commit();
        if (req.isReplyRequired()) {
            reply.setDelay(transaction.getFlowControlDelay());
            reply.setOk(true);
        }
        if (producerId == -1)
            producer.close();
    } catch (Exception e) {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/produce messages failed: " + e.getMessage());
        if (req.isReplyRequired()) {
            reply.setOk(false);
            reply.setException(e);
        }
    }
    if (req.isReplyRequired())
        reply.send();
}
Also used : QueuePushTransaction(com.swiftmq.swiftlet.queue.QueuePushTransaction) InvalidDestinationException(javax.jms.InvalidDestinationException) MessageImpl(com.swiftmq.jms.MessageImpl) QueueImpl(com.swiftmq.jms.QueueImpl) JMSException(javax.jms.JMSException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException)

Example 4 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 {
        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();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) 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)

Example 5 with QueueImpl

use of com.swiftmq.jms.QueueImpl 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 {
        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);
        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();
}
Also used : Entity(com.swiftmq.mgmt.Entity) InvalidSelectorException(javax.jms.InvalidSelectorException) InvalidDestinationException(javax.jms.InvalidDestinationException) 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