Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding an InflaterPostProcessor class. #1094

Closed
dldiehl77 opened this issue Sep 14, 2019 · 2 comments
Closed

Consider adding an InflaterPostProcessor class. #1094

dldiehl77 opened this issue Sep 14, 2019 · 2 comments

Comments

@dldiehl77
Copy link
Contributor

Enhancement

I've created my own InflaterPostProcessor class, that is very much like and in the spirit of your existing GUnzipPostProcessor and UnzipPostProcessor classes. The source code for the class is like so:

public static class InflaterPostProcessor extends AbstractDecompressingPostProcessor {
        public InflaterPostProcessor() {
        }

        public InflaterPostProcessor(boolean alwaysDecompress) {
            super(alwaysDecompress);
        }

        protected InputStream getDecompressorStream(InputStream zipped) throws IOException {
            return new InflaterInputStream(zipped);
        }

        protected String getEncoding() {
            return "deflate";
        }
}

To use this class, I create an instance of it and add it to a DelegatingDecompressingPostProcessor, and set that on my SimpleRabbitListenerContainerFactory (or simply "factory" here):

DelegatingDecompressingPostProcessor postProcessor = new DelegatingDecompressingPostProcessor();
postProcessor.addDecompressor("deflate", new InflaterPostProcessor());
factory.setAfterReceivePostProcessors(postProcessor);

While this certainly isn't much code, I still think it would be nice if guys added this to your codebase. The DelegatingDecompressingPostProcessor class constructor would then change to:

public DelegatingDecompressingPostProcessor() {
    this.decompressors.put("gzip", new GUnzipPostProcessor());
    this.decompressors.put("zip", new UnzipPostProcessor());
    this.decompressors.put("deflate", new InflaterPostProcessor());
}

I'm sure it would also make sense to create an DeflaterPostProcessor class that does the opposite; performs the compression for a message using a DeflaterOutputStream. We currently use a home-grown utility class for doing that, but would gladly switch to using such as class were it to exist in the Spring AMQP library.

Thanks in advance.

@artembilan
Copy link
Member

Sounds like a good candidate for Contribution! Please, go ahead and raise a Pull Request. We will review it ASAP

Thanks

@dldiehl77
Copy link
Contributor Author

I just submitted the Pull Request to add these classes and related unit tests. This was the first time I ever did anything like this, so please be patient with me if I did something wrong. --Dave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants