Compressing & decompressing in mule

  • Published on
    14-Aug-2015

  • View
    237

  • Download
    12

Transcript

1. By Anirban Sen Chowdhary 2. . 3. Fortunately we have gzip-compress-transformer and gzip- uncompress-transformer available in our Mule 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 5. Our corresponding Mule flow will be as follows :- 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 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 8. We can see our compressed file here in location E:backuptestnewfolder :- 9. Now what about decompressing the file back to the original size ??? 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 11. The corresponding our Mule flow will be :- 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 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