0

We would like to decompress a byte array using Spring Integration and are experiencing the following exception upon using unzip-transformer:

org.springframework.integration.handler.ReplyRequiredException: No reply produced by handler 'org.springframework.integration.handler.MessageHandlerChain#1$child#1' ., and its 'requiresReply' property is set to true.,failedMessage=GenericMessage [payload=byte[327] ...

This is the .xml blob we are trying to use for this effort:

int-zip:unzip-transformer result-type="BYTE_ARRAY" expect-single-result="true"/>

The equivalent java code using service-activator works fine for decompression:

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
GZIPInputStream gzipInputStream;
gzipInputStream = new GZIPInputStream(new ByteArrayInputStream((byte[]) 
message.getPayload()));
IOUtils.copy(gzipInputStream, byteArrayOutputStream);
byteArrayOutputStream.close();
return new String(byteArrayOutputStream.toByteArray(), Charsets.UTF_8);

Is there any way to do the same code using unzip-transformer?

Aleksandar G
  • 1,163
  • 2
  • 20
  • 25
  • You need to share some simple application to reproduce the issue. Not clear right now what and how to do to get the same exception. Thanks for understanding – Artem Bilan Oct 27 '18 at 02:15
  • I built a spring application to reproduce this error:https://github.com/praveenKumar88/springproject . You can reproduce this behavior by executing this test:https://github.com/praveenKumar88/springproject/blob/master/src/test/java/GzipUtilTest.java#L50 . Hope this helps – Praveen Kumar Oct 28 '18 at 21:10

1 Answers1

0

GZIPInputStream ... The Spring Integration ZIP doesn't support GZIP, only regular ZIP with entries. That's how you get that exception:

 if (uncompressedData.isEmpty()) {
                if (logger.isWarnEnabled()) {
                    logger.warn("No data unzipped from payload with message Id " + message.getHeaders().getId());
                }
                unzippedData = null;
            }

Just because the ZipUtil.iterate(InputStream is, ZipEntryCallback action) has nothing to iterate over GZIP payload.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • Hi Artem, Do you have any thoughts on a work-around for this? Would you say the best practice for dealing with this with spring integration is using service-activator and the java code mentioned above or is there a better way? Do you also foresee the gzip feature being implemented in future versions of spring? – Praveen Kumar Oct 28 '18 at 20:13
  • Yes, service activator for custom code is the solution for now. I think we have an open issue fo gzip support there, but no plans when we come back for the fix. Contribution is welcome! – Artem Bilan Oct 28 '18 at 21:17
  • Can you please share the issue link? I would love to contribute towards the fix. – Praveen Kumar Oct 28 '18 at 22:35