SlideShare a Scribd company logo
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
www.whishworks.comwww.whishworks.com
Mule ESB- Data Validation- Best
Practices
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Overview
• Validation of data in ESB application at different layers of message
processing is a requirement which is quite frequent.
• Often, the validation logic is implemented at different layers which
is time consuming and also prone to errors.
• Therefore, it is necessary to separate domain model and the
validation logic, further to it, it also has to be aimed for reuse with
the help of framework.
• This presentation focuses to bring the goodness of JSR303 Bean
Validation model [Hibernate RI], Spring framework’s support for
custom validation and a blend on how it will work in MuleSoft ESB.
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Deploying Mule Applications
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Validation Requirements
• From an ESB point of view, the validation requirements are:
• Provide uniform approach to validate different type of payloads
supporting REST, SOAP, XML, Java VO and other types of payloads
• Provide support for field level validations (example: validate
inbound message attributes)
• Provide support for custom validations (based on business logic)
• Support context specific messages for validation errors from
configuration files
• Raise validation errors for handling alternate flow of execution
• Inject validators as pluggable components in flow
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Mule offerings and shortcomings
• Mule supports validations to an extent but that is not
sufficient; for example
• The validator pattern from Mule supports validation using
MEL which is barely sufficient; forcing to write MEL for every
attribute and has no option to wire to an error code/message
• The JSON validator checks whether the input JSON is
formatted. It does not support features to apply a constraint
like checking the length of an attribute, for null value or for an
empty string, etc.
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Benefits of JSR303 specification
• Java Bean Validation (JSR303) is a framework as part of Java EE.
• The bean validation defines meta model and API for data validation.
• The implementation is done through annotations and is extensible, which
can be reused by simply adding annotations to the domain model.
// Example – define constraints to a bean
public class Person {
@NotNull (message=’ERR-BS-001’)
public class Person{
@NotNull (message=’ERR-BS-001’)
@Size(min=1, max=16)
private String firstName;
@NotNull (message=’ERR-BS-002’)
@Size(min=1, max=16)
private String lastName;
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
• Spring framework supports JSR303 bean validations and support for
custom validation. Some of the advantages upon using Spring
Validators are mentioned below:
• Spring framework is a natural choice of Mule for DI – No additional
set-up is required
• Custom Spring Validators can be injected to a Mule ESB flow so as
to validate business logic
• Supports JSR 303 validation by making use of a reference
implementation like Hibernate Validator API or Apache BVal API
• Link validation errors using Spring property placeholders for error
messages which are context specific
7
Benefits of Spring Validators
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
A validation framework is necessary, which binds annotation
validators, custom validators and error message handler.
8
Blending all together
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
• To validate annotations, JSR303 RI is required in the
library. Hibernate Validator or Apache’s BVal can be used to
support annotation based validations.
• To validate concrete domain models, Spring framework’s
ValidationUtils class should be used (from
springframework.validation package). The ValidationUtil’s method
should invoke a custom validator thus providing FieldErrors.
• The ExceptionFactory consolidates the FieldErrors from different
validators, fetches the attribute name and message ID and loads the
message from the message source.
• Custom validators to the ValidationUtils should be injected as
Spring beans in Mule.
• Exception factory should use Spring’s PropertiesFactoryBean to load
error messages at runtime.
9
Cont..
2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
• It might be possible to use annotations in order to validate REST
requests by using @Valid annotation.
• Mule ESB 6.1 has upgraded Jersey version 2.11 (RI) which supports
validation using @Valid annotation prior to a REST method
invocation (like in Spring MVC).
// update user profile after validation
@POST
@Consumes( MediaType.APPLICATION_JSON_VALUE )
public boolean updateProfile(
@Valid UserProfile mProfile )
//…
}
10
Go for the extra mile!

More Related Content

PDF
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
PPTX
MuleSoft CloudHub API Versioning
PPTX
Mulesoft meetup slides mumbai_20113019_exception_handling
PDF
Deep Dive on CI/CD NYC Meet Up Group
PPTX
MuleSoft Meetup slides_kualalumpur_19thSept_Undisturbed REST: Achieving Undis...
PPTX
Indianapolis mulesoft meetup_sep_11_2021
PPTX
Meetup_Bangalore_Rajesh
PPTX
Automate mule deployments with github actions and travis ci
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
MuleSoft CloudHub API Versioning
Mulesoft meetup slides mumbai_20113019_exception_handling
Deep Dive on CI/CD NYC Meet Up Group
MuleSoft Meetup slides_kualalumpur_19thSept_Undisturbed REST: Achieving Undis...
Indianapolis mulesoft meetup_sep_11_2021
Meetup_Bangalore_Rajesh
Automate mule deployments with github actions and travis ci

What's hot (20)

PPTX
How Secure is Your API?
PDF
Mule soft mcia-level-1 Dumps
PPTX
First Caracas MuleSoft Meetup Slides
PDF
MuleSoft Manchester Meetup #2 slides 29th October 2019
PDF
MuleSoft Surat Virtual Meetup#36 - MuleSoft Composer for Salesforce - No Code...
PPTX
Learn mulesoft from scratch
PPTX
Second Caracas MuleSoft Meetup Slides
ODP
PPTX
NYC MuleSoft Meetup 2019 Q2- MuleSoft for Mobile Applications
PPTX
Meetup bangalore-may22nd2021
PDF
MuleSoft Surat Virtual Meetup#15 - Caching Scope, Caching Strategy and Jenkin...
PDF
Nashik MuleSoft Virtual Meetup#1 - Shared and Dedicated Load Balancer
PDF
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
PDF
MuleSoft Surat Virtual Meetup#35 - Setting up MuleSoft Runtime and Anypoint C...
PDF
WHISHWORKS-MuleSoft Hyderabad Meetup -Oct 2018
PDF
MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...
PDF
Nagpur MuleSoft Meetup Group - Working with API Groups in Mulesoft
PDF
TDD for Microservices
PPTX
Caching strategies in MuleSoft
PDF
MuleSoft certified platform architect-level 1 Real Exam Questions
How Secure is Your API?
Mule soft mcia-level-1 Dumps
First Caracas MuleSoft Meetup Slides
MuleSoft Manchester Meetup #2 slides 29th October 2019
MuleSoft Surat Virtual Meetup#36 - MuleSoft Composer for Salesforce - No Code...
Learn mulesoft from scratch
Second Caracas MuleSoft Meetup Slides
NYC MuleSoft Meetup 2019 Q2- MuleSoft for Mobile Applications
Meetup bangalore-may22nd2021
MuleSoft Surat Virtual Meetup#15 - Caching Scope, Caching Strategy and Jenkin...
Nashik MuleSoft Virtual Meetup#1 - Shared and Dedicated Load Balancer
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#35 - Setting up MuleSoft Runtime and Anypoint C...
WHISHWORKS-MuleSoft Hyderabad Meetup -Oct 2018
MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...
Nagpur MuleSoft Meetup Group - Working with API Groups in Mulesoft
TDD for Microservices
Caching strategies in MuleSoft
MuleSoft certified platform architect-level 1 Real Exam Questions
Ad

Viewers also liked (7)

PPTX
Nathan m ebola
PDF
Ebola virus disease
PDF
Ebola, ethical issues
PPTX
Ebola ppt
PPTX
Ebola ppt
PPT
Ebola ppt
PPTX
Ebola presentation
Nathan m ebola
Ebola virus disease
Ebola, ethical issues
Ebola ppt
Ebola ppt
Ebola ppt
Ebola presentation
Ad

Similar to Mule ESB- Data Validation- Best Practices (20)

PPTX
Mule soft esb – data validation best practices
PPTX
.NET microservices with Azure Service Fabric
PPTX
Global Azure Bootcamp: Azure service fabric
PPTX
Refactoring Legacy Web Forms for Test Automation
PDF
Take Your Web Development To The Next Level With These Top 2 Libraries
PDF
Microsoft ALM Support - Testing Perspective
PPTX
NIC - Windows Azure Pack - Level 300
PDF
New ThousandEyes Product Features and Release Highlights: March 2024
PDF
Zure Azure PaaS Zero to Hero - DevOps training day
PPTX
Azure service fabric overview
PPTX
A project on spring framework by rohit malav
PPTX
Fluent validation
PPTX
Azure service fabric
PPTX
NServiceBus Mule ESB Comparison
PDF
Validation for APIs in Laravel 4
PPT
DevOps and Automation for Bioinformaticians
PDF
05 test infrastructure
PPTX
Microservices with Azure Service Fabric
PDF
Patterns and practices for building enterprise-scale HTML5 apps
PPTX
Mule soft esb – data validation best practices
.NET microservices with Azure Service Fabric
Global Azure Bootcamp: Azure service fabric
Refactoring Legacy Web Forms for Test Automation
Take Your Web Development To The Next Level With These Top 2 Libraries
Microsoft ALM Support - Testing Perspective
NIC - Windows Azure Pack - Level 300
New ThousandEyes Product Features and Release Highlights: March 2024
Zure Azure PaaS Zero to Hero - DevOps training day
Azure service fabric overview
A project on spring framework by rohit malav
Fluent validation
Azure service fabric
NServiceBus Mule ESB Comparison
Validation for APIs in Laravel 4
DevOps and Automation for Bioinformaticians
05 test infrastructure
Microservices with Azure Service Fabric
Patterns and practices for building enterprise-scale HTML5 apps

More from Coforge (Erstwhile WHISHWORKS) (15)

PDF
Implementing your APIs with zero trust
PDF
Performing a successful technical debt assessment in Salesforce
PDF
Kafka in banking infographic
PDF
The use of data in 2020 and beyond
PDF
10 things to consider when planning your Mule 4 migration
PDF
WHISHWORKS-MuleSoft Hyderabad Meetup -April 2019
PDF
7 steps to Predictive Analytics
PDF
Big Data into the MuleSoft world
PDF
Integration Snapshot 2018/2019
PDF
Big Data Snapshot - June 2018
PPTX
SUEZ Business Transformation Journey
PPTX
Telecom Service Integration
PPTX
Microservices with Mule
PPTX
Message oriented middleware
PPTX
Best way to Deploy a Mule ESB Application
Implementing your APIs with zero trust
Performing a successful technical debt assessment in Salesforce
Kafka in banking infographic
The use of data in 2020 and beyond
10 things to consider when planning your Mule 4 migration
WHISHWORKS-MuleSoft Hyderabad Meetup -April 2019
7 steps to Predictive Analytics
Big Data into the MuleSoft world
Integration Snapshot 2018/2019
Big Data Snapshot - June 2018
SUEZ Business Transformation Journey
Telecom Service Integration
Microservices with Mule
Message oriented middleware
Best way to Deploy a Mule ESB Application

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Approach and Philosophy of On baking technology
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Encapsulation theory and applications.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
KodekX | Application Modernization Development
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectroscopy.pptx food analysis technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation_ Review paper, used for researhc scholars
Approach and Philosophy of On baking technology
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Electronic commerce courselecture one. Pdf
NewMind AI Weekly Chronicles - August'25 Week I
Encapsulation theory and applications.pdf
Unlocking AI with Model Context Protocol (MCP)
Network Security Unit 5.pdf for BCA BBA.
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Mobile App Security Testing_ A Comprehensive Guide.pdf
KodekX | Application Modernization Development
Advanced methodologies resolving dimensionality complications for autism neur...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Mule ESB- Data Validation- Best Practices

  • 1. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential www.whishworks.comwww.whishworks.com Mule ESB- Data Validation- Best Practices
  • 2. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Overview • Validation of data in ESB application at different layers of message processing is a requirement which is quite frequent. • Often, the validation logic is implemented at different layers which is time consuming and also prone to errors. • Therefore, it is necessary to separate domain model and the validation logic, further to it, it also has to be aimed for reuse with the help of framework. • This presentation focuses to bring the goodness of JSR303 Bean Validation model [Hibernate RI], Spring framework’s support for custom validation and a blend on how it will work in MuleSoft ESB.
  • 3. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Deploying Mule Applications
  • 4. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Validation Requirements • From an ESB point of view, the validation requirements are: • Provide uniform approach to validate different type of payloads supporting REST, SOAP, XML, Java VO and other types of payloads • Provide support for field level validations (example: validate inbound message attributes) • Provide support for custom validations (based on business logic) • Support context specific messages for validation errors from configuration files • Raise validation errors for handling alternate flow of execution • Inject validators as pluggable components in flow
  • 5. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Mule offerings and shortcomings • Mule supports validations to an extent but that is not sufficient; for example • The validator pattern from Mule supports validation using MEL which is barely sufficient; forcing to write MEL for every attribute and has no option to wire to an error code/message • The JSON validator checks whether the input JSON is formatted. It does not support features to apply a constraint like checking the length of an attribute, for null value or for an empty string, etc.
  • 6. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Benefits of JSR303 specification • Java Bean Validation (JSR303) is a framework as part of Java EE. • The bean validation defines meta model and API for data validation. • The implementation is done through annotations and is extensible, which can be reused by simply adding annotations to the domain model. // Example – define constraints to a bean public class Person { @NotNull (message=’ERR-BS-001’) public class Person{ @NotNull (message=’ERR-BS-001’) @Size(min=1, max=16) private String firstName; @NotNull (message=’ERR-BS-002’) @Size(min=1, max=16) private String lastName;
  • 7. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential • Spring framework supports JSR303 bean validations and support for custom validation. Some of the advantages upon using Spring Validators are mentioned below: • Spring framework is a natural choice of Mule for DI – No additional set-up is required • Custom Spring Validators can be injected to a Mule ESB flow so as to validate business logic • Supports JSR 303 validation by making use of a reference implementation like Hibernate Validator API or Apache BVal API • Link validation errors using Spring property placeholders for error messages which are context specific 7 Benefits of Spring Validators
  • 8. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential A validation framework is necessary, which binds annotation validators, custom validators and error message handler. 8 Blending all together
  • 9. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential • To validate annotations, JSR303 RI is required in the library. Hibernate Validator or Apache’s BVal can be used to support annotation based validations. • To validate concrete domain models, Spring framework’s ValidationUtils class should be used (from springframework.validation package). The ValidationUtil’s method should invoke a custom validator thus providing FieldErrors. • The ExceptionFactory consolidates the FieldErrors from different validators, fetches the attribute name and message ID and loads the message from the message source. • Custom validators to the ValidationUtils should be injected as Spring beans in Mule. • Exception factory should use Spring’s PropertiesFactoryBean to load error messages at runtime. 9 Cont..
  • 10. 2014 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential • It might be possible to use annotations in order to validate REST requests by using @Valid annotation. • Mule ESB 6.1 has upgraded Jersey version 2.11 (RI) which supports validation using @Valid annotation prior to a REST method invocation (like in Spring MVC). // update user profile after validation @POST @Consumes( MediaType.APPLICATION_JSON_VALUE ) public boolean updateProfile( @Valid UserProfile mProfile ) //… } 10 Go for the extra mile!