11
Dynamic File Attribute in Mule By Anirban Sen Chowdhary

Dynamic file attribute

Embed Size (px)

Citation preview

Page 1: Dynamic file attribute

Dynamic File Attribute in Mule

By Anirban Sen Chowdhary

Page 2: Dynamic file attribute

Mule ESB has different types of connector or components all around for performing different types of functions. Mule is actually very dynamic and flexible towards it’s user and provide them a lot of feature in different ways.One of the important component and connector is File.

The File connector allows our Mule application to exchange files with a file system. We can implement the File connector as an inbound endpoint (as a message source), or as an outbound endpoint.

Generally a File component and connectors are configured with a flow during design time. But it is also possible to set the File component/connector attributes value dynamically at runtime.

Page 3: Dynamic file attribute

How can we set the attributes value Dynamically? 

Page 4: Dynamic file attribute

Let us consider we have a JSON file as following :-

{ "Folder": "E:/test", "Pattern": "abc.json", "WorkDirectory": "E:/test/New folder"}

Here you can see the JSON input contains the folder name, pattern and work directory given. Now we will design a Mule flow where the file will be read by Mule’s file inbound endpoint, parse the JSON and put the values as the attribute of the file outbound endpoint, where the file will be dispatched… and all this will be set dynamically !!!

Page 5: Dynamic file attribute

Let’s consider our Mule flow as following :-

Here you can see, the file is read, parsed the values and then set those values in outbound endpoints using Mule variables

Page 6: Dynamic file attribute

Now let’s test our flow by placing the file in the inbound folder E:\tmp as follows :-

Page 7: Dynamic file attribute

Now, we can see the value of outbound path E:\test is taken from the input file and the file is placed in the path E:\test :-

Page 8: Dynamic file attribute

Now, we can see the file has been pasted in the path E:\test which s taken from the input file :-

Page 9: Dynamic file attribute

So, here you can see how to use a Dynamically set the attributes of a file outbound component and connectors during runtime, you can try this with other component as well !!!….

Page 10: Dynamic file attribute

In my next slide I will bring some other techniques in Mule implementation .Hope you have enjoyed this simpler version. Keep sharing your knowledge and let our Mule community grow

Page 11: Dynamic file attribute

Thank You