By Walter Lindsay, Director of Solution Architecture, Liaison Technologies
I was recently asked if Contivo transforms run easily on the Mule ESB. Yes. Since the answer is the same for the Spring ESB, and many other Java environments, I’ll describe the answer for Mule here.
Mule is an open-source ESB. It provides, AbstractMessageTransformer, a place on which to hang data transformations. AbstractMessageTransformer requires that you implement transformMessage(MuleMessage, String).
For this example, we will look at Java transforms created from Contivo Analyst. Whether you want to work with XML, flat file, or whatever data, the basic steps are:
- Decide the ways you want to specify which Contivo transform to run. You can specify the transform by name (in the constructor or through a property in the MuleMessage), or you can specify the transform by class. It is easiest to pass that information in through the constructor (or through a property in the MuleMessage).
- Decide the kinds of input data you want to process, such as a SAXSource, InputStream, or any other of numerous ways of specifying the input data. You will register the input data formats via the registerSourceType method.
- Decide on the kind of output data you want to return, and inform Mule via the setReturnType method. In Mule, XML data is often returned from transforms as a byte array.
- In the transformMessage method, use the Contivo API to transform the input data into the output data:
try {
final TransformAny transformer = …; // pass in the transform definition
transformer.addSource(message.getPayload());
final DocSpec out = …; // for instance, put the output in a byte array
transfomer.toTargetDoc(out);
return …; // return the output – for instance a byte array
}
catch (Exception e)
{
Once you fill in the gaps in the code, you will be ready to generate and test transforms.
Leave A Reply!