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 Summary
FieldsFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a post processor that will include theMessageProperties.SPRING_AUTO_DECOMPRESSheader set to 'true'.AbstractCompressingPostProcessor(boolean autoDecompress) Construct a post processor that will include (or not include) theMessageProperties.SPRING_AUTO_DECOMPRESSheader. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract OutputStreamgetCompressorStream(OutputStream stream) Get the stream.protected abstract StringGet the encoding.intgetOrder()postProcessMessage(Message message) Change (or replace) the message.voidsetCopyProperties(boolean copyProperties) Flag to indicate ifMessagePropertiesshould be used as is or cloned for new message after compression.voidsetEncodingDelimiter(String encodingDelimiter) Set a delimiter to be added between the compression type and the original encoding, if any.protected voidsetOrder(int order) Set the order.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.amqp.core.MessagePostProcessor
postProcessMessage, postProcessMessage
-
Field Details
-
logger
-
-
Constructor Details
-
AbstractCompressingPostProcessor
public AbstractCompressingPostProcessor()Construct a post processor that will include theMessageProperties.SPRING_AUTO_DECOMPRESSheader set to 'true'. -
AbstractCompressingPostProcessor
public AbstractCompressingPostProcessor(boolean autoDecompress) Construct a post processor that will include (or not include) theMessageProperties.SPRING_AUTO_DECOMPRESSheader. 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 ifMessagePropertiesshould 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
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
Description copied from interface:MessagePostProcessorChange (or replace) the message.- Specified by:
postProcessMessagein interfaceMessagePostProcessor- Parameters:
message- the message.- Returns:
- the message.
- Throws:
AmqpException- an exception.
-
getOrder
public int getOrder() -
setOrder
protected void setOrder(int order) Set the order.- Parameters:
order- the order, default 0.- See Also:
-
getCompressorStream
Get the stream.- Parameters:
stream- The output stream to write the compressed data to.- Returns:
- the compressor output stream.
- Throws:
IOException- IOException
-
getEncoding
Get the encoding.- Returns:
- the content-encoding header.
-