| 20 March 2009 |
I am currently busy to evaluate Mule. I am busy setting up an integration platform and I want to see what role Mule may have in there. Based on the documentation it could be an important role but that is according to the documentation, of course I want to see it for myself to make sure. The reason why Mule was selected (there are a lot of similar products like OpenESB and ServiceMix) as favorite was because the nice integration with Maven and the ease with which you can setup unit tests. For me the best way to evaluate a product is by using it and getting familiar with it. So I downloaded the newest version (2.2.0), installed it and got myself a book about Mule2 (in this case "Mule 2 A Developer's guide" from 'firstpress'). I prefer to use a book to force myself to evaluate the product by a kind of structured way, instead of just jumping from one example to another.
So by going through the book I got to the first example and I also ran into the first challenge. The example given looked like the following situation (I assume Mule is installed correctly):
- Create a Maven project for a Mule project
- Modify the default config file
-
<mule>
-
<model name="main">
-
<service name="Square">
-
<inbound>
-
<vm:inbound-endpoint path="math" synchronous="true" />
-
</inbound>
-
<component class="net.pascalalma.mule.Square"/>
-
<outbound>
-
<pass-through-router>
-
<vm:outbound-endpoint path="inverse"/>
-
</pass-through-router>
-
</outbound>
-
</service>
-
<service name="Inverse">
-
<inbound>
-
<vm:inbound-endpoint path="inverse" />
-
</inbound>
-
<component class="net.pascalalma.mule.Inverse" />
-
<outbound>
-
<pass-through-router>
-
<stdio:outbound-endpoint system="OUT"/>
-
</pass-through-router>
-
</outbound>
-
</service>
-
</model>
-
</mule>
- Create the necessary Java classes
- Create the test class
-
package net.pascalalma.mule.mathservice;
-
-
import java.util.Map;
-
import org.mule.DefaultMuleMessage;
-
import org.mule.api.MuleMessage;
-
import org.mule.module.client.MuleClient;
-
import org.mule.tck.FunctionalTestCase;
-
-
public class MathServiceTestCase extends FunctionalTestCase {
-
-
return "mule-config.xml";
-
}
-
-
MuleClient client = new MuleClient();
-
-
-
-
-
assertEquals("-25", result.getPayloadAsString());
-
-
}
-
}
- Run the project
I used the Mule Project Archetype:
mvn mul-project-archetype:create -DartifactId=net.pascalalma.mule -DmuleVersion=2.2.0
See the docs for more detail info about the use of this archetype.
To tell Mule what to do you have to supply a config file on the classpath. Default you will get an empty one created by the archetype. I put in the following (according to the example of the book):
As you can see in the config file there are two components defined which are actually just pojo's like this:
and
Next is to create the class with which we can test the configuration of Mule. I created this class (taken as exampe from the book):
Now we can clean and build the project with
mvn clean install
However the build failed because the test failed!
Problem was that the result of the unit test didn't match the result I expected nor what was expected in the book! Of course, this wasn't a good thing in the evaluation of Mule. I mean, the first example I try leads to unexpected results. But because I am aware that it was far to early in the evaluation process to drop Mule as a candidate, I gave it another chance. I posted my situation on the Mule mailinglist. This is also a very important aspect of the evaluation: is the community behind the product still alive and active.
Well, in one word: yes, it is! Within a few hours I had the answer to my problem and within one day the answer was extended with some more background info why the showed behaviour differs from the one that was described in the book.
Now, these kind of things gives me confidence about the product, so I will definitely continue with the evaluation because I still believe the 'tool' can be of great value in our solution.
About the issue: it appears that Mule has changed the default value for the parameter 'defaultSynchronousEndpoints' from 'true' to 'false' in a later version of Mule. So in my case I had to add synchronous="true" to each endpoint or set the value of 'defaultSynchronousEndpoints' to 'true'.


1 comment to 'Mule 2: First impression'
18 November 2009
[...] EJB3 with Mule and test it with OpenEJB 1 April 2009 Pascal Alma Like I said here we are evaluating Mule to see if we can use it in our situation. One of the things we must do with [...]