org.apache.activemq.artemis.core.server.LargeServerMessage

Here are the examples of the java api class org.apache.activemq.artemis.core.server.LargeServerMessage taken from open source projects.

1. StompSession#sendInternalLarge()

Project: activemq-artemis
Source File: StompSession.java
View license
public void sendInternalLarge(ServerMessageImpl message, boolean direct) throws Exception {
    int headerSize = message.getHeadersAndPropertiesEncodeSize();
    if (headerSize >= connection.getMinLargeMessageSize()) {
        throw BUNDLE.headerTooBig();
    }
    StorageManager storageManager = ((ServerSessionImpl) session).getStorageManager();
    long id = storageManager.generateID();
    LargeServerMessage largeMessage = storageManager.createLargeMessage(id, message);
    byte[] bytes = new byte[message.getBodyBuffer().writerIndex() - MessageImpl.BODY_OFFSET];
    message.getBodyBuffer().readBytes(bytes);
    largeMessage.addBytes(bytes);
    largeMessage.releaseResources();
    largeMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, bytes.length);
    session.send(largeMessage, direct);
    largeMessage = null;
}

2. PostOfficeImpl#confirmLargeMessageSend()

View license
/**
    * @param tx
    * @param message
    * @throws Exception
    */
private void confirmLargeMessageSend(Transaction tx, final ServerMessage message) throws Exception {
    LargeServerMessage largeServerMessage = (LargeServerMessage) message;
    if (largeServerMessage.getPendingRecordID() >= 0) {
        if (tx == null) {
            storageManager.confirmPendingLargeMessage(largeServerMessage.getPendingRecordID());
        } else {
            storageManager.confirmPendingLargeMessageTX(tx, largeServerMessage.getMessageID(), largeServerMessage.getPendingRecordID());
        }
        largeServerMessage.setPendingRecordID(-1);
    }
}

3. ServerSessionImpl#sendLarge()

View license
@Override
public void sendLarge(final MessageInternal message) throws Exception {
    // need to create the LargeMessage before continue
    long id = storageManager.generateID();
    LargeServerMessage largeMsg = storageManager.createLargeMessage(id, message);
    if (logger.isTraceEnabled()) {
        logger.trace("sendLarge::" + largeMsg);
    }
    if (currentLargeMessage != null) {
        ActiveMQServerLogger.LOGGER.replacingIncompleteLargeMessage(currentLargeMessage.getMessageID());
    }
    currentLargeMessage = largeMsg;
}

4. JournalStorageManager#parseLargeMessage()

View license
@Override
protected /**
    * @param messages
    * @param buff
    * @return
    * @throws Exception
    */
LargeServerMessage parseLargeMessage(final Map<Long, ServerMessage> messages, final ActiveMQBuffer buff) throws Exception {
    LargeServerMessage largeMessage = createLargeMessage();
    LargeMessageEncoding messageEncoding = new LargeMessageEncoding(largeMessage);
    messageEncoding.decode(buff);
    if (largeMessage.containsProperty(Message.HDR_ORIG_MESSAGE_ID)) {
        // for compatibility: couple with old behaviour, copying the old file to avoid message loss
        long originalMessageID = largeMessage.getLongProperty(Message.HDR_ORIG_MESSAGE_ID);
        SequentialFile currentFile = createFileForLargeMessage(largeMessage.getMessageID(), true);
        if (!currentFile.exists()) {
            SequentialFile linkedFile = createFileForLargeMessage(originalMessageID, true);
            if (linkedFile.exists()) {
                linkedFile.copyTo(currentFile);
                linkedFile.close();
            }
        }
        currentFile.close();
    }
    return largeMessage;
}