Search in sources :

Example 1 with MessageImpl

use of com.swiftmq.jms.MessageImpl 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 MessageImpl

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

the class Message method copyMessage.

private MessageImpl copyMessage(MessageImpl msg) throws Exception {
    DataByteArrayOutputStream dbos = new DataByteArrayOutputStream(4096);
    DataByteArrayInputStream dbis = new DataByteArrayInputStream();
    dbos.rewind();
    msg.writeContent(dbos);
    dbis.reset();
    dbis.setBuffer(dbos.getBuffer(), 0, dbos.getCount());
    MessageImpl msgCopy = MessageImpl.createInstance(dbis.readInt());
    msgCopy.readContent(dbis);
    msgCopy.clearSwiftMQAllProps();
    return msgCopy;
}
Also used : DataByteArrayOutputStream(com.swiftmq.tools.util.DataByteArrayOutputStream) DataByteArrayInputStream(com.swiftmq.tools.util.DataByteArrayInputStream) MessageImpl(com.swiftmq.jms.MessageImpl)

Example 3 with MessageImpl

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

the class Message method copyProperties.

/**
 * Internal use only.
 */
public Message copyProperties(Message source) throws JMSException {
    ensureLocalCopy();
    MessageImpl sourceImpl = source.getImpl();
    for (Enumeration _e = sourceImpl.getPropertyNames(); _e.hasMoreElements(); ) {
        String name = (String) _e.nextElement();
        _impl.setObjectProperty(name, sourceImpl.getObjectProperty(name));
    }
    return this;
}
Also used : Enumeration(java.util.Enumeration) MessageImpl(com.swiftmq.jms.MessageImpl)

Example 4 with MessageImpl

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

the class MessageConsumerImpl method reportDelivered.

protected void reportDelivered(Message message, boolean duplicate) {
    try {
        MessageIndex messageIndex = ((MessageImpl) message).getMessageIndex();
        requestRegistry.request(new MessageDeliveredRequest(this, mySession.dispatchId, serverQueueConsumerId, messageIndex, duplicate));
    } catch (Exception e) {
    }
}
Also used : MessageIndex(com.swiftmq.swiftlet.queue.MessageIndex) MessageImpl(com.swiftmq.jms.MessageImpl) IllegalStateException(javax.jms.IllegalStateException)

Example 5 with MessageImpl

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

the class MessageConsumerImpl method addToCache.

void addToCache(AsyncMessageDeliveryRequest request) {
    if (isClosed())
        return;
    if (request.isRequiresRestart())
        fillCachePending = false;
    MessageImpl msg = request.getMessageEntry().getMessage();
    if (request.getConnectionId() != mySession.myConnection.getConnectionId()) {
        if (MessageTracker.enabled) {
            MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { mySession.myConnection.toString(), mySession.toString(), toString() }, "addToCache, invalid connectionId (" + request.getConnectionId() + " vs " + mySession.myConnection.getConnectionId() + ")");
        }
        return;
    }
    if (MessageTracker.enabled) {
        MessageTracker.getInstance().track(msg, new String[] { mySession.myConnection.toString(), mySession.toString(), toString() }, "addToCache");
    }
    messageCache.add(request);
}
Also used : MessageImpl(com.swiftmq.jms.MessageImpl)

Aggregations

MessageImpl (com.swiftmq.jms.MessageImpl)106 JMSException (javax.jms.JMSException)42 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)33 InvalidSelectorException (javax.jms.InvalidSelectorException)31 ResourceLimitException (com.swiftmq.swiftlet.auth.ResourceLimitException)28 QueueImpl (com.swiftmq.jms.QueueImpl)21 DataByteArrayInputStream (com.swiftmq.tools.util.DataByteArrayInputStream)20 TopicImpl (com.swiftmq.jms.TopicImpl)17 MessageEntry (com.swiftmq.swiftlet.queue.MessageEntry)15 MessageIndex (com.swiftmq.swiftlet.queue.MessageIndex)15 RingBuffer (com.swiftmq.tools.collection.RingBuffer)14 InvalidDestinationException (javax.jms.InvalidDestinationException)14 List (java.util.List)13 EntityList (com.swiftmq.mgmt.EntityList)10 Message (javax.jms.Message)10 XidImpl (com.swiftmq.jms.XidImpl)6 DataByteArrayOutputStream (com.swiftmq.tools.util.DataByteArrayOutputStream)6 MessageSelector (com.swiftmq.ms.MessageSelector)5 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)4 ArrayList (java.util.ArrayList)4