Search in sources :

Example 26 with MessageReference

use of org.apache.activemq.artemis.core.server.MessageReference in project activemq-artemis by apache.

the class QueueImpl method debug.

public String debug() {
    StringWriter str = new StringWriter();
    PrintWriter out = new PrintWriter(str);
    out.println("queueMemorySize=" + queueMemorySize);
    for (ConsumerHolder holder : consumerList) {
        out.println("consumer: " + holder.consumer.debug());
    }
    for (MessageReference reference : intermediateMessageReferences) {
        out.print("Intermediate reference:" + reference);
    }
    if (intermediateMessageReferences.isEmpty()) {
        out.println("No intermediate references");
    }
    boolean foundRef = false;
    synchronized (this) {
        Iterator<MessageReference> iter = messageReferences.iterator();
        while (iter.hasNext()) {
            foundRef = true;
            out.println("reference = " + iter.next());
        }
    }
    if (!foundRef) {
        out.println("No permanent references on queue");
    }
    System.out.println(str.toString());
    return str.toString();
}
Also used : StringWriter(java.io.StringWriter) MessageReference(org.apache.activemq.artemis.core.server.MessageReference) PrintWriter(java.io.PrintWriter)

Example 27 with MessageReference

use of org.apache.activemq.artemis.core.server.MessageReference in project activemq-artemis by apache.

the class QueueImpl method sendMessageToDeadLetterAddress.

@Override
public synchronized boolean sendMessageToDeadLetterAddress(final long messageID) throws Exception {
    try (LinkedListIterator<MessageReference> iter = iterator()) {
        while (iter.hasNext()) {
            MessageReference ref = iter.next();
            if (ref.getMessage().getMessageID() == messageID) {
                incDelivering(ref);
                sendToDeadLetterAddress(null, ref);
                iter.remove();
                refRemoved(ref);
                return true;
            }
        }
        return false;
    }
}
Also used : MessageReference(org.apache.activemq.artemis.core.server.MessageReference)

Example 28 with MessageReference

use of org.apache.activemq.artemis.core.server.MessageReference in project activemq-artemis by apache.

the class QueueImpl method deleteReference.

@Override
public synchronized boolean deleteReference(final long messageID) throws Exception {
    boolean deleted = false;
    Transaction tx = new TransactionImpl(storageManager);
    try (LinkedListIterator<MessageReference> iter = iterator()) {
        while (iter.hasNext()) {
            MessageReference ref = iter.next();
            if (ref.getMessage().getMessageID() == messageID) {
                incDelivering(ref);
                acknowledge(tx, ref);
                iter.remove();
                refRemoved(ref);
                deleted = true;
                break;
            }
        }
        if (!deleted) {
            // Look in scheduled deliveries
            deleted = scheduledDeliveryHandler.removeReferenceWithID(messageID) != null ? true : false;
        }
        tx.commit();
        return deleted;
    }
}
Also used : Transaction(org.apache.activemq.artemis.core.transaction.Transaction) TransactionImpl(org.apache.activemq.artemis.core.transaction.impl.TransactionImpl) BindingsTransactionImpl(org.apache.activemq.artemis.core.transaction.impl.BindingsTransactionImpl) MessageReference(org.apache.activemq.artemis.core.server.MessageReference)

Example 29 with MessageReference

use of org.apache.activemq.artemis.core.server.MessageReference in project activemq-artemis by apache.

the class QueueImpl method changeReferencesPriority.

@Override
public synchronized int changeReferencesPriority(final Filter filter, final byte newPriority) throws Exception {
    try (LinkedListIterator<MessageReference> iter = iterator()) {
        int count = 0;
        while (iter.hasNext()) {
            MessageReference ref = iter.next();
            if (filter == null || filter.match(ref.getMessage())) {
                count++;
                iter.remove();
                refRemoved(ref);
                ref.getMessage().setPriority(newPriority);
                addTail(ref, false);
            }
        }
        return count;
    }
}
Also used : MessageReference(org.apache.activemq.artemis.core.server.MessageReference)

Example 30 with MessageReference

use of org.apache.activemq.artemis.core.server.MessageReference in project activemq-artemis by apache.

the class QueueImpl method doInternalPoll.

private synchronized void doInternalPoll() {
    int added = 0;
    MessageReference ref;
    while ((ref = intermediateMessageReferences.poll()) != null) {
        internalAddTail(ref);
        if (!ref.isPaged()) {
            messagesAdded.incrementAndGet();
        }
        if (added++ > MAX_DELIVERIES_IN_LOOP) {
            // if we just keep polling from the intermediate we could starve in case there's a sustained load
            deliverAsync();
            return;
        }
    }
}
Also used : MessageReference(org.apache.activemq.artemis.core.server.MessageReference)

Aggregations

MessageReference (org.apache.activemq.artemis.core.server.MessageReference)82 ArrayList (java.util.ArrayList)29 QueueImpl (org.apache.activemq.artemis.core.server.impl.QueueImpl)26 Test (org.junit.Test)26 FakeConsumer (org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer)18 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)17 Transaction (org.apache.activemq.artemis.core.transaction.Transaction)14 Message (org.apache.activemq.artemis.api.core.Message)12 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)11 TransactionImpl (org.apache.activemq.artemis.core.transaction.impl.TransactionImpl)11 Queue (org.apache.activemq.artemis.core.server.Queue)10 HashMap (java.util.HashMap)9 NoSuchElementException (java.util.NoSuchElementException)9 Map (java.util.Map)8 Filter (org.apache.activemq.artemis.core.filter.Filter)7 LinkedList (java.util.LinkedList)5 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)5 ActiveMQIllegalStateException (org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException)4 BindingsTransactionImpl (org.apache.activemq.artemis.core.transaction.impl.BindingsTransactionImpl)4 HashSet (java.util.HashSet)3