Search in sources :

Example 6 with LargeServerMessage

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

the class PagedMessageImpl method initMessage.

@Override
public void initMessage(StorageManager storage) {
    if (largeMessageLazyData != null) {
        LargeServerMessage lgMessage = storage.createLargeMessage();
        ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(largeMessageLazyData);
        lgMessage = LargeMessagePersister.getInstance().decode(buffer, lgMessage);
        lgMessage.incrementDelayDeletionCount();
        lgMessage.setPaged();
        this.message = lgMessage;
        largeMessageLazyData = null;
    }
}
Also used : LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Example 7 with LargeServerMessage

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

the class Page method delete.

public boolean delete(final PagedMessage[] messages) throws Exception {
    if (storageManager != null) {
        storageManager.pageDeleted(storeName, pageId);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Deleting pageNr=" + pageId + " on store " + storeName);
    }
    if (messages != null) {
        for (PagedMessage msg : messages) {
            if (msg.getMessage() instanceof ICoreMessage && (msg.getMessage()).isLargeMessage()) {
                LargeServerMessage lmsg = (LargeServerMessage) msg.getMessage();
                // Remember, cannot call delete directly here
                // Because the large-message may be linked to another message
                // or it may still being delivered even though it has been acked already
                lmsg.decrementDelayDeletionCount();
            }
        }
    }
    try {
        if (suspiciousRecords) {
            ActiveMQServerLogger.LOGGER.pageInvalid(file.getFileName(), file.getFileName());
            file.renameTo(file.getFileName() + ".invalidPage");
        } else {
            file.delete();
        }
        return true;
    } catch (Exception e) {
        ActiveMQServerLogger.LOGGER.pageDeleteError(e);
        return false;
    }
}
Also used : ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) PagedMessage(org.apache.activemq.artemis.core.paging.PagedMessage) LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage) IOException(java.io.IOException)

Example 8 with LargeServerMessage

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

the class BridgeImpl method handle.

@Override
public HandleStatus handle(final MessageReference ref) throws Exception {
    if (filter != null && !filter.match(ref.getMessage())) {
        return HandleStatus.NO_MATCH;
    }
    synchronized (this) {
        if (!active || !session.isWritable(this)) {
            if (logger.isDebugEnabled()) {
                logger.debug(this + "::Ignoring reference on bridge as it is set to inactive ref=" + ref);
            }
            return HandleStatus.BUSY;
        }
        if (blockedOnFlowControl) {
            return HandleStatus.BUSY;
        }
        if (deliveringLargeMessage) {
            return HandleStatus.BUSY;
        }
        if (logger.isTraceEnabled()) {
            logger.trace("Bridge " + this + " is handling reference=" + ref);
        }
        ref.handled();
        synchronized (refs) {
            refs.put(ref.getMessage().getMessageID(), ref);
        }
        final SimpleString dest;
        if (forwardingAddress != null) {
            dest = forwardingAddress;
        } else {
            // Preserve the original address
            dest = ref.getMessage().getAddressSimpleString();
        }
        final Message message = beforeForward(ref.getMessage(), dest);
        pendingAcks.countUp();
        try {
            if (message.isLargeMessage()) {
                deliveringLargeMessage = true;
                deliverLargeMessage(dest, ref, (LargeServerMessage) message);
                return HandleStatus.HANDLED;
            } else {
                return deliverStandardMessage(dest, ref, message);
            }
        } catch (Exception e) {
            // If an exception happened, we must count down immediately
            pendingAcks.countDown();
            throw e;
        }
    }
}
Also used : LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage) Message(org.apache.activemq.artemis.api.core.Message) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQInterruptedException(org.apache.activemq.artemis.api.core.ActiveMQInterruptedException)

Example 9 with LargeServerMessage

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

the class ActiveMQServerImpl method loadJournals.

private JournalLoadInformation[] loadJournals() throws Exception {
    JournalLoader journalLoader = activation.createJournalLoader(postOffice, pagingManager, storageManager, queueFactory, nodeManager, managementService, groupingHandler, configuration, parentServer);
    JournalLoadInformation[] journalInfo = new JournalLoadInformation[2];
    List<QueueBindingInfo> queueBindingInfos = new ArrayList<>();
    List<GroupingInfo> groupingInfos = new ArrayList<>();
    List<AddressBindingInfo> addressBindingInfos = new ArrayList<>();
    journalInfo[0] = storageManager.loadBindingJournal(queueBindingInfos, groupingInfos, addressBindingInfos);
    recoverStoredConfigs();
    Map<Long, AddressBindingInfo> addressBindingInfosMap = new HashMap<>();
    journalLoader.initAddresses(addressBindingInfosMap, addressBindingInfos);
    Map<Long, QueueBindingInfo> queueBindingInfosMap = new HashMap<>();
    journalLoader.initQueues(queueBindingInfosMap, queueBindingInfos);
    journalLoader.handleGroupingBindings(groupingInfos);
    Map<SimpleString, List<Pair<byte[], Long>>> duplicateIDMap = new HashMap<>();
    HashSet<Pair<Long, Long>> pendingLargeMessages = new HashSet<>();
    List<PageCountPending> pendingNonTXPageCounter = new LinkedList<>();
    journalInfo[1] = storageManager.loadMessageJournal(postOffice, pagingManager, resourceManager, queueBindingInfosMap, duplicateIDMap, pendingLargeMessages, pendingNonTXPageCounter, journalLoader);
    journalLoader.handleDuplicateIds(duplicateIDMap);
    for (Pair<Long, Long> msgToDelete : pendingLargeMessages) {
        ActiveMQServerLogger.LOGGER.deletingPendingMessage(msgToDelete);
        LargeServerMessage msg = storageManager.createLargeMessage();
        msg.setMessageID(msgToDelete.getB());
        msg.setPendingRecordID(msgToDelete.getA());
        msg.setDurable(true);
        msg.deleteFile();
    }
    if (pendingNonTXPageCounter.size() != 0) {
        try {
            journalLoader.recoverPendingPageCounters(pendingNonTXPageCounter);
        } catch (Throwable e) {
            ActiveMQServerLogger.LOGGER.errorRecoveringPageCounter(e);
        }
    }
    journalLoader.cleanUp();
    return journalInfo;
}
Also used : PageCountPending(org.apache.activemq.artemis.core.persistence.impl.PageCountPending) GroupingInfo(org.apache.activemq.artemis.core.persistence.GroupingInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Pair(org.apache.activemq.artemis.api.core.Pair) ConcurrentHashSet(org.apache.activemq.artemis.utils.collections.ConcurrentHashSet) HashSet(java.util.HashSet) QueueBindingInfo(org.apache.activemq.artemis.core.persistence.QueueBindingInfo) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) LinkedList(java.util.LinkedList) JournalLoadInformation(org.apache.activemq.artemis.core.journal.JournalLoadInformation) AddressBindingInfo(org.apache.activemq.artemis.core.persistence.AddressBindingInfo) LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage)

Example 10 with LargeServerMessage

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

the class ServerConsumerImpl method proceedDeliver.

@Override
public void proceedDeliver(MessageReference reference) throws Exception {
    try {
        Message message = reference.getMessage();
        if (server.hasBrokerPlugins()) {
            server.callBrokerPlugins(plugin -> plugin.beforeDeliver(this, reference));
        }
        if (message.isLargeMessage() && supportLargeMessage) {
            if (largeMessageDeliverer == null) {
                // This can't really happen as handle had already crated the deliverer
                // instead of throwing an exception in weird cases there is no problem on just go ahead and create it
                // again here
                largeMessageDeliverer = new LargeMessageDeliverer((LargeServerMessage) message, reference);
            }
            // The deliverer was prepared during handle, as we can't have more than one pending large message
            // as it would return busy if there is anything pending
            largeMessageDeliverer.deliver();
        } else {
            deliverStandardMessage(reference, message);
        }
    } finally {
        lockDelivery.readLock().unlock();
        callback.afterDelivery();
        if (server.hasBrokerPlugins()) {
            server.callBrokerPlugins(plugin -> plugin.afterDeliver(this, reference));
        }
    }
}
Also used : LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) Message(org.apache.activemq.artemis.api.core.Message) LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage)

Aggregations

LargeServerMessage (org.apache.activemq.artemis.core.server.LargeServerMessage)17 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)6 Message (org.apache.activemq.artemis.api.core.Message)5 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)2 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)2 Pair (org.apache.activemq.artemis.api.core.Pair)2 JournalLoadInformation (org.apache.activemq.artemis.core.journal.JournalLoadInformation)2 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)2 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)2 PagedMessage (org.apache.activemq.artemis.core.paging.PagedMessage)2 PageTransactionInfoImpl (org.apache.activemq.artemis.core.paging.impl.PageTransactionInfoImpl)2 CursorAckRecordEncoding (org.apache.activemq.artemis.core.persistence.impl.journal.codec.CursorAckRecordEncoding)2 DeliveryCountUpdateEncoding (org.apache.activemq.artemis.core.persistence.impl.journal.codec.DeliveryCountUpdateEncoding)2 DuplicateIDEncoding (org.apache.activemq.artemis.core.persistence.impl.journal.codec.DuplicateIDEncoding)2