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