Thursday, February 11, 2010

Using the Mule Data Integrator

I started using MDI last week, and stumbled over and over again over glitches. Very little documentation and a brand new product donot make a good couple. I managed to successfully do an object to object mapping and on the way solved quite a few errors
Here are some pointers. Other technologies in the mix are Mule ESB, Mule MQ , eclipse , Mysql and Oracle.

1. Download and install Mule Data Integrator. After the installation is complete , a data-int folder should be created inside your mule home folder (MULE_HOME variable definitely needs to be set).


2. Assuming that you are using eclipse with mule, go to help-> software update->install to install MDI IDE. All these steps are there in the installation guide so I am just going to skip over to the part where you have the MDI Examples (read-only) directory shows up in your eclipse project explorer.

3. As the first step what you need to do is copy the example folder , paste it using a different name in your workspace. I call it here as "mymapping". I have noticed that when you try creating an actual mapping file, it finds only this project in the file creation wizard.
4. Create a mule project and include examples from MDI ( there is a little checkbox in the bottom) . This creates a mule project for you with some example data-int configuration files uner the conf folder.
5. Have your java beans ready . Implement them as serializable . Otherwise sending them over Mule MQ will generate error.

6. Donot forget to include the MDI jar in your buildpath. Or else it will not recognise the namespace for data-int. This was my error number 1.
7. In the "mymapping" mdi project, import your java bean classes under the Structures folder. Copying and pasting them usually doesnt work. This is probably because they get converted into xml structures while MDI imports them. If you go to the actual folder on the disk, you will see xml representations of the jars/classes you imported. This was the second error I did, I copy pasted my class files under the Structures folder. They started giving and error when I tried to include them in the actual mapping.


8. In your mule configuration add the data-int transformer declaration and use this transformer in the transformer-ref .
I faced some very peculiar problems while using this transformer
a> ERROR : Make sure the document is in Xstream format .
This error occurs if you have serializable in the bean but you havent specified sourcetype/ resulttype parameters in your transformer mapping . Your mule transformer mapping should have the sourceType ="JAVA" and resultType ="JAVA" if you are doing a java bean to java bean mapping.
b> data-int:project should be specified and be the name of the the MDI project in my case, "mymapping". Make a zip of this folder once you are done creating your mapping, and place it under the mule_home->data int-> project folder . The data-int:project tag has an attribute called archive where you have to specify the path to the zip of your mdi project. If your MULE_HOME is set, by default it looks under the above specified path.

c> when I applied the transformer in my inbound enpoint I repeatedly got an error saying
the transformer need a valid endpoint. The DataIntregatorTransformer calls the ObjectToJmsMessageTransformer and endpoints like STDIO and JMS generate this error.
If this transformer is applied at the outbound endpoint , this error is removed.
I am not very sure if there is another workaround, but the above strategy worked for me.
Here is an example of my mule config

Hope this helps.


























































































































No comments:

Post a Comment