franz1981 commented on issue #2694: ARTEMIS-2371 Message with huge header shuts 
broker down
URL: https://github.com/apache/activemq-artemis/pull/2694#issuecomment-499080624
 
 
   I'm not totally sure about it, but we could put a check even before in the 
process chain ie
   ```java
      private static Message asLargeMessage(Message message, StorageManager 
storageManager) throws Exception {
         ICoreMessage coreMessage = message.toCore();
         //in order to avoid headers
         if (message.isDurable()) {
            final int estimatedHeaderSize = 
coreMessage.getHeadersAndPropertiesEncodeSize();
            if (estimatedHeaderSize > storageManager.getMaxRecordSize()) {
               throw new ActiveMQLargeMessageException("The large message has a 
too big header size");
            }
         }
         LargeServerMessage lsm = 
storageManager.createLargeMessage(storageManager.generateID(), coreMessage);
         ActiveMQBuffer buffer = coreMessage.getReadOnlyBodyBuffer();
         final int readableBytes = buffer.readableBytes();
         lsm.addBytes(buffer);
         lsm.releaseResources();
         lsm.putLongProperty(Message.HDR_LARGE_BODY_SIZE, readableBytes);
         return lsm;
      }
   ```
   Not sure if `isDurable` and `getHeadersAndPropertiesEncodeSize` are the 
correct methods , but the idea is to avoid that regardless the protocol used a 
large message won't be created/replicated at all if the journal is not able to 
persist it

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to