Search code examples
muleesb

What is the difference between mule Java Transformer and Java Component


I would like to know: What are the major differences between Mule Java Transformer and Java Component? When should we use one over another ?


Solution

  • The Java component helps the developer to create a custom Java code that executes when the component receives a message.The Java class can contains anything like a normal Java class that can have attributes, method or Object instance etc. The Java component generally used to enhance the functionality and capability of our web-based applications written in Java. If you want to trigger some more complex set of processes coded in Java, or your complex business logic you should better use Java component Java component can be also configured as interceptors which act on received messages, like logging errors or exceptions, or applying some business logic, or even invoking additional Java services. Reference :- https://developer.mulesoft.com/docs/display/current/Java+Component+Reference

    On the other hand Java transformer can be used to create a custom transformer that can change or modify the message payload The Java transformer applies all these configuration settings to each message, then sends the transformed message to the next building block in your flow. Java transformer is generally used if our transformation logic is more complex . Reference :- https://developer.mulesoft.com/docs/display/current/Java+Transformer+Reference and http://blog.pmug.info/2015/02/06/working-with-custom-transformers-in-mulesoft-anypoint-studio/

    Some more reference on similar topic :- http://forums.mulesoft.com/questions/1985/what-is-the-different-of-java-component-and-java-transformer-at-function-to-convert-a-data-type-to-another.html