SlideShare una empresa de Scribd logo
1 de 16
MULE: JAVA TRANSFORMER
ENABLES THE DEVELOPER TO PACKAGE CUSTOM JAVA
CODE
BASIC CONSIDERATIONS
• Anypoint Studio provides a set of transformers to
handle the most common data transformation
scenarios
• Developer can chain transformers if a transformer did
not exist for specific needs
• The DataWeave Transform Message component can be
used in place of most other transformers
SPECIAL CASES
• Transforming complex data structures
• Applying complex business rules
• The available transformers cannot meet the
requirement
• Simply throw the old lines of code into a component
instead of having to reengineer the code’s behavior
through a series of different Mule components
POSSIBLE SOLUTIONS
• Building custom components and/or transformers
• Turning to the most favorite Programming Languages:
o Java
o .NET
o Scripting languages: Groovy, Javascript, Python or Ruby
JAVA
• Java is the native language in which Mule is coded
• The Java component enables the developer to package
custom Java code that executes when the component
receives a message
• The Java component can be used to enhance the
functionality and capability of your web-based
applications written in Java
JAVA TRANSFORMER (1/2)
• Transforms a message from its original
format to a new, modified format.
• If rather than just changing the
message/payload, trigger a more complex
set of processes coded in Java, use a Java
Component.
JAVA TRANSFORMER (2/2)
To configure the Java
Transformer, selecting a
class is the only required
entry:
• Browse for an existing Java
class
• Add a new Java class
BASIC JAVA CLASS
• A class must extends:
o org.mule.transformer.AbstractMessageTransformer
Modifies the message and returns it as the output
message of the transformer.
o org.mule.transformer.AbstractTransformer
Modifies the payload and returns it as the output
payload.
• A class must be referenced in a fully-qualified name
JAVA CLASS: MESSAGE (1/3)
package com.mulesoft.learning;
import java.util.Map;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractMessageTransformer;
public class MessageTransformer extends AbstractMessageTransformer {
@Override
public Object transformMessage(MuleMessage message, String
outputEncoding) throws TransformerException {
Map<String, String> params =
message.getInboundProperty("http.query.params");
message.setInvocationProperty("myProperty", "Hello, " +
params.get("name"));
return message;
}
}
JAVA CLASS: MESSAGE (2/3)
The class has access to Mule Message:
• Inbound Properties
• Outbound Properties
• Payload
• Attachments
JAVA CLASS: MESSAGE (3/3)
Run/debug a simple flow
• http://localhost:8081/?name=Max
• It will produce a variable
myProperty, and its value is: Hello,
Max
• It will keep the payload as is
JAVA CLASS: PAYLOAD (1/3)
package com.mulesoft.learning;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractTransformer;
public class PayloadTransformer extends AbstractTransformer {
@Override
protected Object doTransform(Object src, String enc) throws
TransformerException {
return "Hello, " + src;
}
}
JAVA CLASS: PAYLOAD (2/3)
The class has only access to Payload, therefore:
• Add new Byte Array to String Transformer
• Update the custom-transformer class to refer to the new
class
JAVA CLASS: PAYLOAD (3/3)
Run/debug the new flow
• Post a raw message: Max
• Send it to http://localhost:8081
• It will produce a new payload: Hello, Max
SUMMARY
Mule allows developers to:
• Build their own component and/or transformer
• Simply write their favorite programming language
• Choose the transformation scope
RESOURCES:
• https://docs.mulesoft.com/mule-user-guide/v/3.8/java-
transformer-reference

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Mule java part-1
Mule java part-1Mule java part-1
Mule java part-1
 
Mule esb introduction
Mule esb introductionMule esb introduction
Mule esb introduction
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
 
Mule Custom Aggregator
Mule Custom AggregatorMule Custom Aggregator
Mule Custom Aggregator
 
Mule rabbit mq
Mule rabbit mqMule rabbit mq
Mule rabbit mq
 
Message structure
Message structureMessage structure
Message structure
 
Mule esb usecase
Mule esb usecaseMule esb usecase
Mule esb usecase
 
Mule UDP Transport
Mule UDP TransportMule UDP Transport
Mule UDP Transport
 
Mule expression language
Mule expression languageMule expression language
Mule expression language
 
Mule system properties
Mule system propertiesMule system properties
Mule system properties
 
Mule esb
Mule esbMule esb
Mule esb
 
Mule dataweave
Mule dataweaveMule dataweave
Mule dataweave
 
Mule jms
Mule   jmsMule   jms
Mule jms
 
Connecting to external_application
Connecting to external_applicationConnecting to external_application
Connecting to external_application
 
Mule Expression Transformer
Mule Expression TransformerMule Expression Transformer
Mule Expression Transformer
 
Mule soa
Mule soaMule soa
Mule soa
 
Mule Amazon SNS Connector
Mule Amazon SNS ConnectorMule Amazon SNS Connector
Mule Amazon SNS Connector
 
Muleflowarchitecturepart2
Muleflowarchitecturepart2Muleflowarchitecturepart2
Muleflowarchitecturepart2
 
Rabbit Mq in Mule
Rabbit Mq in MuleRabbit Mq in Mule
Rabbit Mq in Mule
 
Mule esb
Mule esbMule esb
Mule esb
 

Similar a Mule: Java Transformer

Similar a Mule: Java Transformer (20)

Custom transformer and annotation
Custom transformer and annotationCustom transformer and annotation
Custom transformer and annotation
 
Ashok mule esb
Ashok mule esbAshok mule esb
Ashok mule esb
 
Java modulesystem
Java modulesystemJava modulesystem
Java modulesystem
 
Mule esb and_relevant_components
Mule esb and_relevant_componentsMule esb and_relevant_components
Mule esb and_relevant_components
 
Transformers in Mulesoft Anypoint
Transformers in Mulesoft AnypointTransformers in Mulesoft Anypoint
Transformers in Mulesoft Anypoint
 
Muletransformers
MuletransformersMuletransformers
Muletransformers
 
Mule transformers
Mule transformersMule transformers
Mule transformers
 
A short introduction on anypoint transformers
A short introduction on anypoint transformersA short introduction on anypoint transformers
A short introduction on anypoint transformers
 
Creating custom transformer
Creating custom transformerCreating custom transformer
Creating custom transformer
 
Java features
Java featuresJava features
Java features
 
Mule ESB
Mule ESBMule ESB
Mule ESB
 
ForEach scope
ForEach scopeForEach scope
ForEach scope
 
Srilekha mule esb
Srilekha mule esbSrilekha mule esb
Srilekha mule esb
 
Mule slides
Mule slides Mule slides
Mule slides
 
Mule esb kranthi
Mule esb kranthiMule esb kranthi
Mule esb kranthi
 
Mule esb kranthi
Mule esb kranthiMule esb kranthi
Mule esb kranthi
 
Mule esb
Mule esb Mule esb
Mule esb
 
Mule
MuleMule
Mule
 
Esb process
Esb processEsb process
Esb process
 
Mule
MuleMule
Mule
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 

Último (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 

Mule: Java Transformer

  • 1. MULE: JAVA TRANSFORMER ENABLES THE DEVELOPER TO PACKAGE CUSTOM JAVA CODE
  • 2. BASIC CONSIDERATIONS • Anypoint Studio provides a set of transformers to handle the most common data transformation scenarios • Developer can chain transformers if a transformer did not exist for specific needs • The DataWeave Transform Message component can be used in place of most other transformers
  • 3. SPECIAL CASES • Transforming complex data structures • Applying complex business rules • The available transformers cannot meet the requirement • Simply throw the old lines of code into a component instead of having to reengineer the code’s behavior through a series of different Mule components
  • 4. POSSIBLE SOLUTIONS • Building custom components and/or transformers • Turning to the most favorite Programming Languages: o Java o .NET o Scripting languages: Groovy, Javascript, Python or Ruby
  • 5. JAVA • Java is the native language in which Mule is coded • The Java component enables the developer to package custom Java code that executes when the component receives a message • The Java component can be used to enhance the functionality and capability of your web-based applications written in Java
  • 6. JAVA TRANSFORMER (1/2) • Transforms a message from its original format to a new, modified format. • If rather than just changing the message/payload, trigger a more complex set of processes coded in Java, use a Java Component.
  • 7. JAVA TRANSFORMER (2/2) To configure the Java Transformer, selecting a class is the only required entry: • Browse for an existing Java class • Add a new Java class
  • 8. BASIC JAVA CLASS • A class must extends: o org.mule.transformer.AbstractMessageTransformer Modifies the message and returns it as the output message of the transformer. o org.mule.transformer.AbstractTransformer Modifies the payload and returns it as the output payload. • A class must be referenced in a fully-qualified name
  • 9. JAVA CLASS: MESSAGE (1/3) package com.mulesoft.learning; import java.util.Map; import org.mule.api.MuleMessage; import org.mule.api.transformer.TransformerException; import org.mule.transformer.AbstractMessageTransformer; public class MessageTransformer extends AbstractMessageTransformer { @Override public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { Map<String, String> params = message.getInboundProperty("http.query.params"); message.setInvocationProperty("myProperty", "Hello, " + params.get("name")); return message; } }
  • 10. JAVA CLASS: MESSAGE (2/3) The class has access to Mule Message: • Inbound Properties • Outbound Properties • Payload • Attachments
  • 11. JAVA CLASS: MESSAGE (3/3) Run/debug a simple flow • http://localhost:8081/?name=Max • It will produce a variable myProperty, and its value is: Hello, Max • It will keep the payload as is
  • 12. JAVA CLASS: PAYLOAD (1/3) package com.mulesoft.learning; import org.mule.api.transformer.TransformerException; import org.mule.transformer.AbstractTransformer; public class PayloadTransformer extends AbstractTransformer { @Override protected Object doTransform(Object src, String enc) throws TransformerException { return "Hello, " + src; } }
  • 13. JAVA CLASS: PAYLOAD (2/3) The class has only access to Payload, therefore: • Add new Byte Array to String Transformer • Update the custom-transformer class to refer to the new class
  • 14. JAVA CLASS: PAYLOAD (3/3) Run/debug the new flow • Post a raw message: Max • Send it to http://localhost:8081 • It will produce a new payload: Hello, Max
  • 15. SUMMARY Mule allows developers to: • Build their own component and/or transformer • Simply write their favorite programming language • Choose the transformation scope