Would you like chicken or pasta? Chocolate or vanilla? Coffee or tea? White wine or red? Component or transformer? If you have a piece of custom code, should you implement it as a custom transformer or as a custom component?
Technically, you can do either. But under what circumstances is it better to use a transformer versus a component?
Hello friends! How’s it going?
Has the following ever happened to you? You show up to work one morning and your boss tells you, “I need you to take this data and turn it into XML.” Well, this has happened to me, and in this blog post I’m going to show you how to do this quickly.
Working with web APIs, local APIs and different data formats and structures is too damn hard. You have to write painful verbose code to:
- Query Web APIs and work with the data
- Enrich and join data from external services with local services
- Compose RESTful services from existing services
- Version services and data formats
- Merge data from different sources into a common data format
- Sort through sets of data
Last week I posted about Writing Mule Transformers, this week I’m going to continue with some more advanced features users can take advantage of.
All objects in Mule have lifecycle associated with them. Lifecycle calls can be added as necessary. For transformers, there are two lifecycle methods that are most useful.
By default the AbstractEventAwareTransfromer and AbstractTransformer both implement the org.mule.
Transformers in Mule are simple objects that convert the current message from one type to another. The interface for a transformer is simple, but there are some tips and tricks for getting the most out of transformers. For this post we will define a transformer the converts from an Order object to HTML so that we can email the details of an order to a customer.
The Mule expression framework was one of the new features in Mule 2. It provides a very powerful way to make queries on incoming messages and use the results to control how Mule behaves. Mule already supports a variety of expression languages such as Xpath and Groovy. There is also expressions for navigating the current message headers, payload and attachments.