Support Questions
Find answers, ask questions, and share your expertise

Nifi CompressContent - Got this exception "IOException thrown from CompressContent: java.io.IOException: Input is not in the .gz format"

Nifi CompressContent - Got this exception "IOException thrown from CompressContent: java.io.IOException: Input is not in the .gz format"

New Contributor

Hi,

 

I am new to Nifi and trying to do a POC on below flow.

 

I get XML messages from a Kakfa topic. I need to consume the XML message get few attributes and data which is GZIP compressed format from XML elements, GZIP decompress the data (which is again an XML) and then load to MySQL DB. I am trying this and got stuck in below step.

 

(1)ConsumeKafka → (2)EvaluateXPath (flowfile-attribute = I set few XML elements as flowfile-attributes which is useful downstream) → (3)EvaluateXPath (flowfile-content = get gzip data using XPATH expression = string(//ABC/data) ) → (4)UpdateAttribute (mime.type = application/gzip) → (5) CompressContent (Compression Format = use mime.type attribute and mode = decompress)

 

My CompressContent is failing with below Exception.

 

org.apache.nifi.processor.exception.ProcessException: IOException thrown from CompressContent[id=be4b9583-016e-1000-7cce-b9d822334c4c]: java.io.IOException: java.io.IOException: Input is not in the .gz format

 

It could be because my datatype of flowfile-content from (3)EvaluateXPath is set to String. Do I need to convert String to byte before feeding to CompressContent? If Yes, how can I do that in the same (3)EvaluateXPath by using some kind of function toBytes()?

 

Thanks in advance for your help!!!

1 REPLY 1

Re: Nifi CompressContent - Got this exception "IOException thrown from CompressContent: java.io.IOException: Input is not in the .gz format"

New Contributor

Got the solution for this issue. Data is Base64 encoded and hence the Gzip process is unable to decompress, so I have added "Base64EncodeContent" processor before "CompressContent' (Gzip Decompress) and that solved the issue.