Class AbstractCompressingPostProcessor

java.lang.Object
org.springframework.amqp.support.postprocessor.AbstractCompressingPostProcessor
All Implemented Interfaces:
MessagePostProcessor, Ordered
Direct Known Subclasses:
AbstractDeflaterPostProcessor

public abstract class AbstractCompressingPostProcessor extends Object implements MessagePostProcessor, Ordered
Base class for post processors that compress the message body. The content encoding is set to getEncoding() or getEncoding() + ":" + existing encoding, if present.
Since:
1.4.2
Author:
Gary Russell, Artem Bilan
  • Field Details

    • logger

      protected final Log logger
  • Constructor Details

    • AbstractCompressingPostProcessor

      public AbstractCompressingPostProcessor()
      Construct a post processor that will include the MessageProperties.SPRING_AUTO_DECOMPRESS header set to 'true'.
    • AbstractCompressingPostProcessor

      public AbstractCompressingPostProcessor(boolean autoDecompress)
      Construct a post processor that will include (or not include) the MessageProperties.SPRING_AUTO_DECOMPRESS header. Used by the (Spring AMQP) inbound message converter to determine whether the message should be decompressed automatically, or remain compressed.
      Parameters:
      autoDecompress - true to indicate the receiver should automatically decompress.
  • Method Details

    • setCopyProperties

      public void setCopyProperties(boolean copyProperties)
      Flag to indicate if MessageProperties should be used as is or cloned for new message after compression. By default this flag is turned off for better performance since in most cases the original message is not used any more.
      Parameters:
      copyProperties - clone or reuse original message properties.
      Since:
      2.1.5
    • setEncodingDelimiter

      public void setEncodingDelimiter(String encodingDelimiter)
      Set a delimiter to be added between the compression type and the original encoding, if any. Defaults to ", " (since 2.3); for compatibility with consumers using versions of spring-amqp earlier than 2.2.12, set it to ":" (no trailing space).
      Parameters:
      encodingDelimiter - the delimiter.
      Since:
      2.2.12
    • postProcessMessage

      public Message postProcessMessage(Message message) throws AmqpException
      Description copied from interface: MessagePostProcessor
      Change (or replace) the message.
      Specified by:
      postProcessMessage in interface MessagePostProcessor
      Parameters:
      message - the message.
      Returns:
      the message.
      Throws:
      AmqpException - an exception.
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface Ordered
    • setOrder

      protected void setOrder(int order)
      Set the order.
      Parameters:
      order - the order, default 0.
      See Also:
    • getCompressorStream

      protected abstract OutputStream getCompressorStream(OutputStream stream) throws IOException
      Get the stream.
      Parameters:
      stream - The output stream to write the compressed data to.
      Returns:
      the compressor output stream.
      Throws:
      IOException - IOException
    • getEncoding

      protected abstract String getEncoding()
      Get the encoding.
      Returns:
      the content-encoding header.