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();
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
}
Aggregations