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 togetEncoding()
orgetEncoding()
+ ":" + existing encoding, if present.- Since:
- 1.4.2
- Author:
- Gary Russell, Artem Bilan
-
-
Field Summary
Fields Modifier and Type Field Description protected Log
logger
-
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
-
Constructor Summary
Constructors Constructor Description AbstractCompressingPostProcessor()
Construct a post processor that will include theMessageProperties.SPRING_AUTO_DECOMPRESS
header set to 'true'.AbstractCompressingPostProcessor(boolean autoDecompress)
Construct a post processor that will include (or not include) theMessageProperties.SPRING_AUTO_DECOMPRESS
header.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract OutputStream
getCompressorStream(OutputStream stream)
Get the stream.protected abstract String
getEncoding()
Get the encoding.int
getOrder()
Message
postProcessMessage(Message message)
Change (or replace) the message.void
setCopyProperties(boolean copyProperties)
Flag to indicate ifMessageProperties
should be used as is or cloned for new message after compression.void
setEncodingDelimiter(String encodingDelimiter)
Set a delimiter to be added between the compression type and the original encoding, if any.protected void
setOrder(int order)
Set the order.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.amqp.core.MessagePostProcessor
postProcessMessage, postProcessMessage
-
-
-
-
Field Detail
-
logger
protected final Log logger
-
-
Constructor Detail
-
AbstractCompressingPostProcessor
public AbstractCompressingPostProcessor()
Construct a post processor that will include theMessageProperties.SPRING_AUTO_DECOMPRESS
header set to 'true'.
-
AbstractCompressingPostProcessor
public AbstractCompressingPostProcessor(boolean autoDecompress)
Construct a post processor that will include (or not include) theMessageProperties.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 Detail
-
setCopyProperties
public void setCopyProperties(boolean copyProperties)
Flag to indicate ifMessageProperties
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 interfaceMessagePostProcessor
- Parameters:
message
- the message.- Returns:
- the message.
- Throws:
AmqpException
- an exception.
-
setOrder
protected void setOrder(int order)
Set the order.- Parameters:
order
- the order, default 0.- See Also:
Ordered
-
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.
-
-