Search code examples
javaapache-camelunzipdataformatjbossfuse

Apache Camel (JBoss Fuse) - how to unzip a file from a MQ route?


I am receiving zippeddata on a camel route, running in JBoss Fuse (also known as Fuse ESB).

Having added some log statements, I can see that the incoming data is Bytes (and it looks all scrambled, so I am pretty sure it is zipped data).

However the unmarshall().zip() part of my camel route doesn't unzip the data to text - I still have bytes (and they still look scrambled.

from("webspheremq:topic:SNAPSHOTS")
    .log("before unzip, body class is: ${body.class}")   // bytes in...
    .unmarshall().zip()
    .log("after unzip, body class is: ${body.class}")   // still bytes! not good.

I am obviously doing something wrong here.

So I had a look at this question: Unzip files with Apache Camel?

But unfortunately camel-zipfile does not seem available to me in the JBoss Fuse environment I am working in, so I couldn't use ZipSplitter().

Can someone please tell me how to unzip data in an Apache Camel route in JBoss Fuse?

Thanks in advance for any help.


Solution

  • Ok, it was quite simple:

    from("xyz")
        .unmarshal(new ZipDataFormat())
        .convertBodyTo(String.class)
    

    Hope this helps.