Saddle and Mule Studio symbiosis
- Details
- Published on Friday, 23 March 2012 10:42
As a Mule user, you probably know that they released a cool tool named Mule Studio. It allows you to easily create projects, flows, test... Thus, you may wonder about Saddle's positioning regarding Mule Studio. This post will give you some insights, and even a real-world example of file parsing using both Saddle and Mule, so keep reading!
First, as good as Mule Studio is, it comes with a few drawbacks:
- No support for services-based configs
- As far as we know, no support for other Mule versions than the embedded one
Saddle's Workflow Designer still allows you to use Mule 2.2, 3.0, 3.1, and 3.2 with flows or services (however, like Mule Studio, no services+flows mix).
But the aim here is not to compare Saddle with Mule Studio, but to explain how to benefit from both. For this, we'd like to emphasize that Saddle is not only a graphical, drag and drop workflow designer, but much more:
- Saddle helps you to parse Excel, CSV, HL7 and any flat file, simply by configuring the structure of the file in a Template (a la Smooks). More here and in this tutorial.
- Saddle helps you to write text files according to a given structure (same resuorces as above)
- Saddle provides an API to transform messages from one format into another one, see here
Let's discover how you can use Saddle's parsing and writing functionalities with Mule Studio. If you're unfamiliar with them, have a look at the previous resources.
First step : download the libs
- Go to the Download Page and grab the latest MessageLib and Mule 3.2 Components
- Extract the content of the 2 zip files in any folder of your choice
Second step : import libs into Mule Studio
- Create a new, empty Mule project
- Configure its buld path by right-clicking on the project and select Buil Path -> Configure Build Path
- Go to the "Libraries" tab and select "Add External Jars"
- Include all jars you have previously extracted, and validate with OK
Third step : use the magic
That's it, you're now ready to use Saddle's transformers! But how? Just like any custom transformer! Let's imagine you want the MixedStringToMessageTransformer to parse your input file.
Simply insert a Java Transformer after your File Inbound-Endpoint, and configure it as follows:
- Display name: any name you like
- Transformer class: lu.tudor.santec.mule.transformers.MixedStringToMessageTransformer (all available transformers are in the package lu.tudor.santec.mule.transformers)
- Property: here you set the typical properties. For our example:
- templatePath: path to the template file (required)
- provideAsXML: false by default, which means the Transformer delivers an object of type Field. If true, the Transformer returns a String containing the XML representation of the parsed message that you can later use just like any XML
We hope that we proved how easy it is to combine Saddle with Mule Studio. You can use Saddle to create your templates, and then switch to Mule Studio for the rest. If you have any ideas or commments, don't hesitate to share them here or in our forum.
Maybe you wonder why using the whole Saddle package if you just want to create templates? Good news! We're almost done with providing the Template Designer (and Template Tester) as a Netbeans plugin! Stay tuned, more on this will come soon!