简体   繁体   中英

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

I am receiving zipped data 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.

Ok, it was quite simple:

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

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM