Example usage for org.springframework.amqp.support.postprocessor ZipPostProcessor ZipPostProcessor

List of usage examples for org.springframework.amqp.support.postprocessor ZipPostProcessor ZipPostProcessor

Introduction

In this page you can find the example usage for org.springframework.amqp.support.postprocessor ZipPostProcessor ZipPostProcessor.

Prototype

public ZipPostProcessor() 

Source Link

Usage

From source file:org.springframework.amqp.rabbit.core.BatchingRabbitTemplateTests.java

@Test
public void testSimpleBatchZippedBestCompression() throws Exception {
    BatchingStrategy batchingStrategy = new SimpleBatchingStrategy(2, Integer.MAX_VALUE, 30000);
    BatchingRabbitTemplate template = new BatchingRabbitTemplate(batchingStrategy, this.scheduler);
    template.setConnectionFactory(this.connectionFactory);
    ZipPostProcessor zipPostProcessor = new ZipPostProcessor();
    zipPostProcessor.setLevel(Deflater.BEST_COMPRESSION);
    assertEquals(Deflater.BEST_COMPRESSION, getStreamLevel(zipPostProcessor));
    template.setBeforePublishPostProcessors(zipPostProcessor);
    MessageProperties props = new MessageProperties();
    Message message = new Message("foo".getBytes(), props);
    template.send("", ROUTE, message);
    message = new Message("bar".getBytes(), props);
    template.send("", ROUTE, message);
    message = receive(template);//from www. j  a  va  2  s  . com
    assertEquals("zip", message.getMessageProperties().getContentEncoding());
    UnzipPostProcessor unzipper = new UnzipPostProcessor();
    message = unzipper.postProcessMessage(message);
    assertEquals("\u0000\u0000\u0000\u0003foo\u0000\u0000\u0000\u0003bar", new String(message.getBody()));
}

From source file:org.springframework.amqp.rabbit.core.BatchingRabbitTemplateTests.java

@Test
public void testSimpleBatchZippedWithEncoding() throws Exception {
    BatchingStrategy batchingStrategy = new SimpleBatchingStrategy(2, Integer.MAX_VALUE, 30000);
    BatchingRabbitTemplate template = new BatchingRabbitTemplate(batchingStrategy, this.scheduler);
    template.setConnectionFactory(this.connectionFactory);
    ZipPostProcessor zipPostProcessor = new ZipPostProcessor();
    assertEquals(Deflater.BEST_SPEED, getStreamLevel(zipPostProcessor));
    template.setBeforePublishPostProcessors(zipPostProcessor);
    MessageProperties props = new MessageProperties();
    props.setContentEncoding("foo");
    Message message = new Message("foo".getBytes(), props);
    template.send("", ROUTE, message);
    message = new Message("bar".getBytes(), props);
    template.send("", ROUTE, message);
    message = receive(template);/*from  w w  w . j  a v a  2  s  .  c o  m*/
    assertEquals("zip:foo", message.getMessageProperties().getContentEncoding());
    UnzipPostProcessor unzipper = new UnzipPostProcessor();
    message = unzipper.postProcessMessage(message);
    assertEquals("\u0000\u0000\u0000\u0003foo\u0000\u0000\u0000\u0003bar", new String(message.getBody()));
}