Compressing & decompressing in mule

Download Compressing & decompressing in mule

Post on 14-Aug-2015




12 download


<ol><li> 1. By Anirban Sen Chowdhary </li><li> 2. . </li><li> 3. Fortunately we have gzip-compress-transformer and gzip- uncompress-transformer available in our Mule </li><li> 4. So, to compress a payload in our Mule flow, we can use gzip-compress-transformer as follows :- As you can see we have used a file inbound to pick a file in our flow, and then we compress it with gzip-compress-transformer and the output of the flow will produce a compressed file </li><li> 5. Our corresponding Mule flow will be as follows :- </li><li> 6. As you can see in the code it will pick a file called abc.doc from E:backuptest location , compress it and put the compressed file to E:backuptestnewfolder So, let us place a file abc.doc in the source folder as follows :- You can see the file size is about 83 KB before compression </li><li> 7. Let run our application and we can see, the file has been transferred to location E:backuptestnewfolder You can also see in the log that the payload size before compression was 83.0 KB and size after compression is 21.9912 KB </li><li> 8. We can see our compressed file here in location E:backuptestnewfolder :- </li><li> 9. Now what about decompressing the file back to the original size ??? </li><li> 10. In case of decompressing a file back to original size ( Size before the compression) we will be using gzip-uncompress- transformer as follows:- As you can see, it will pick up the compressed file abc.doc from the location E:backuptestnewfolder and put it into a new location E:backuptestoriginalFileSize </li><li> 11. The corresponding our Mule flow will be :- </li><li> 12. Now if we run the flow, we will get the following in our console :- The file has been decompressed back to its original size into the location E:backuptestoriginalFileSize </li><li> 13. Hope you enjoyed the tips of compressing and decompressing using gzip-compress-transformer/gzip-uncompress-transformer in Mule Next slide I will bring some more simple yet interesting topic </li></ol>


View more >